Hi everyone!
I have 3 scenes called page 1, page 2 and page 3.
On each scene i have a tab bar. The tab bar is also added to the scene group so it doesnt show up in the next scene.
On the tab bar, there is 2 buttons. One button goes to the previous page and the other one goes to the next page.
So for example, on page 1; when you click on previous page it would go to the 3rd page(since there is no page before the 1st page) and if you would click on the next page button, it would go to the 2nd page.
on page 2; when you click on previous page it would go to the 1st page and if you would click on the next page button, it would go to the 3rd page.
on page 3; when you click on previous page it would go to the 2nd page and if you would click on the next page button, it would go to the 1st page(since there is no page after the 4th page) .
However if you click on the next button on the 1st page and then click on the previous button when on the 2nd page, you can not click on the next button on the first page.
How do i fix this? I played around with the code and I couldn’t find the solution.
The tab bar code for each scene is below:
--------------------- --Page 1 Tab Bar Code --------------------- local function onNextView(event) composer.gotoScene("page2") end local function onPreviousView(event) composer.gotoScene("page3") end -- table to setup buttons local tabButtons = { { label="Previous Page", defaultFile="button1.png", overFile="button1-down.png", width = 32, height = 32, onPress=onPreviousView, selected=true,labelColor = { default={ 1, 1, 1 }, over={ 0, 0, 1 } } }, { label="Next Page", defaultFile="button2.png", overFile="button2-down.png", width = 32, height = 32, onPress=onNextView, labelColor = { default={ 1, 1, 1 }, over={ 0, 0, 1 } } }, } -- create the actual tabBar widget local tabBar = widget.newTabBar{ top = display.contentHeight -50, -- 50 is default height for tabBar widget backgroundFile = "tabBar.png", tabSelectedLeftFile = "tabBar.png", tabSelectedMiddleFile = "tabBar.png", tabSelectedRightFile = "tabBar.png", tabSelectedFrameWidth = 40, tabSelectedFrameHeight = 120, buttons = tabButtons } -- all objects must be added to group (e.g. self.view) sceneGroup:insert(tabBar) --------------------- --Page 2 Tab Bar Code --------------------- local function onNextView(event) composer.gotoScene("page3") dock1:hide(250) end local function onPreviousView(event) composer.gotoScene("page1") dock1:hide(250) end -- table to setup buttons local tabButtons = { { label="Previous Page", defaultFile="button1.png", overFile="button1-down.png", width = 32, height = 32, onPress=onPreviousView, selected=true,labelColor = { default={ 1, 1, 1 }, over={ 0, 0, 1 } } }, { label="Next Page", defaultFile="button2.png", overFile="button2-down.png", width = 32, height = 32, onPress=onNextView, labelColor = { default={ 1, 1, 1 }, over={ 0, 0, 1 } } }, } -- create the actual tabBar widget local tabBar = widget.newTabBar{ top = display.contentHeight -50, -- 50 is default height for tabBar widget backgroundFile = "tabBar.png", tabSelectedLeftFile = "tabBar.png", tabSelectedMiddleFile = "tabBar.png", tabSelectedRightFile = "tabBar.png", tabSelectedFrameWidth = 40, tabSelectedFrameHeight = 120, buttons = tabButtons } -- all objects must be added to group (e.g. self.view) sceneGroup:insert(tabBar) --------------------- --Page 3 Tab Bar Code --------------------- local function onNextView(event) composer.gotoScene("page1") dock1:hide(250) end local function onPreviousView(event) composer.gotoScene("page2") dock1:hide(250) end -- table to setup buttons local tabButtons = { { label="Previous Page", defaultFile="button1.png", overFile="button1-down.png", width = 32, height = 32, onPress=onPreviousView, selected=true,labelColor = { default={ 1, 1, 1 }, over={ 0, 0, 1 } } }, { label="Next Page", defaultFile="button2.png", overFile="button2-down.png", width = 32, height = 32, onPress=onNextView, labelColor = { default={ 1, 1, 1 }, over={ 0, 0, 1 } } }, } -- create the actual tabBar widget local tabBar = widget.newTabBar{ top = display.contentHeight -50, -- 50 is default height for tabBar widget backgroundFile = "tabBar.png", tabSelectedLeftFile = "tabBar.png", tabSelectedMiddleFile = "tabBar.png", tabSelectedRightFile = "tabBar.png", tabSelectedFrameWidth = 40, tabSelectedFrameHeight = 120, buttons = tabButtons } -- all objects must be added to group (e.g. self.view) sceneGroup:insert(tabBar)
If you still dont understand my problem; paste in the code and add in the necessary resources/scenes to make it work.