Hello,
can somebody help?
I use the tab bar in my application based on the template of the Corona SDK and I check it out in the tutorial here in Corona SDK API and its successful my app having tab bar. The problem I encountered is whenever I transfer/click the other button and show the other page, some of the object of the said page will appear in the other page. even I will put the object in the scene:show( event ) --> event.phase == “will” or “did” still the object will appear in the other page when you click the other button in the tab bar. code are bellow:
–main.lua-- (based on Corona SDK template with a little changes)
– show default status bar (iOS)
display.setStatusBar( display.DefaultStatusBar )
– include Corona’s “widget” library
local widget = require “widget”
local composer = require “composer”
– event listeners for tab buttons:
local function onFirstView( event )
composer.gotoScene( “view1” )
end
local function onSecondView( event )
composer.gotoScene( “view2” )
end
local function onThirdView( event )
composer.gotoScene( “view3” )
end
local function onForthView( event )
composer.gotoScene( “view4” )
end
– create a tabBar widget with two buttons at the bottom of the screen
– table to setup buttons
local tabButtons = {
{ label=“List”, defaultFile=“list.png”, overFile=“icon1-down.png”, width = 32, height = 32, onPress=onFirstView, selected=true },
{ label=“Register”, defaultFile=“add.png”, overFile=“icon1-down.png”, width = 32, height = 32, onPress=onSecondView },
{ label=“Borrow”, defaultFile=“borrow3.png”, overFile=“icon1-down.png”, width = 32, height = 32, onPress=onThirdView },
{ label=“Pay”, defaultFile=“pay.png”, overFile=“icon1-down.png”, width = 32, height = 32, onPress=onForthView },
}
– create the actual tabBar widget
local tabBar = widget.newTabBar{
top = display.contentHeight - 50, – 50 is default height for tabBar widget
buttons = tabButtons
}
onFirstView() – invoke first tab button’s onPress event manually
– view1.lua – (example)
local txtFname
function scene:create( event )
txtFname = native.newTextField(10,100,screeW-20,25);
end
–view2.lua – (example)
function scene:create( event )
local lable = display.newText(“Text here bla… bla… bla…”, 50, 150, native.systemFont, 18);
end