I’m very new to Corona and am having difficulty working out how to create a tab bar with more than two buttons. The reason I ask is that I have already attempted to create this using the default code with corona for a new app which already has two buttons but when I attempt to add a third it doesn’t run any longer. It works fine until I enter
[lua]
{
defaultFile=“btnForms.png”,
overFile=“btnFormsDown.png”,
width = 106, height = 50,
onPress=onThirdView
},
[/lua]
I’ve also attached all the files that i’m using if it helps. The code in the whole page looks like this…
[lua]
–
– main.lua
–
display.setDefault( “background”, 255, 255, 255 )
display.setStatusBar( display.DefaultStatusBar )
local widget = require “widget”
local composer = require “composer”
– event listeners for tab buttons:
local function onFirstView( event )
composer.gotoScene( “home” )
end
local function onSecondView( event )
composer.gotoScene( “settings” )
end
local function onThirdView( event )
composer.gotoScene( “forms” )
end
– table to setup buttons
local tabButtons = {
{
defaultFile=“btnHome.png”,
overFile=“btnHomeDown.png”,
width = 106, height = 50,
onPress=onFirstView,
selected=true
},
{
defaultFile=“btnSettings.png”,
overFile=“btnSettingsDown.png”,
width = 106, height = 50,
onPress=onSecondView
},
{
defaultFile=“btnForms.png”,
overFile=“btnFormsDown.png”,
width = 106, height = 50,
onPress=onThirdView
},
}
– create the actual tabBar widget
local tabBar = widget.newTabBar{
top = display.contentHeight - 50,
buttons = tabButtons
}
onFirstView() – invoke first tab button’s onPress event manually
[/lua]
Thanks guys. 