Hey
I am using the tabBar controller available in viewController.lua (https://bitbucket.org/gilbert/view-controller-library).
It is working just great on any device and I am very pleased I have found this library for use in all utility apps we make.
BUT… I need to reload the tabbars in some way. There are initialized in main.lua like below.
[lua]local function init()
–Create a group that contains the entire screen and tab bar
mainView = display.newGroup()
–Create a group that contains the screens beneath the tab bar
tabView = display.newGroup()
mainView:insert(tabView)
if (not userID) then
print (“user is 0”)
local path = system.pathForFile( “user.txt”, system.DocumentsDirectory )
– io.open opens a file at path. returns nil if no file found
local fh = io.open( path, “r” )
if fh then
– read all contents of file into a string
userID = fh:read( “*a” )
–native.showAlert(“test”,userID,{“ja”},onComplete)
fh:close()
else
local fw = io.open( path, “w” ) – open/create for write
fw:write(“0”)
fw:close()
end
createTabs()
else
print (“user is not 0”)
createTabs()
end
return true
end
function createTabs()
if (userID == “0”) then
tabBar = viewController.newTabBar{
background = “gfx/tabBar.png”, --tab bar background
tabs = {“Hem”, “Regler”}, --names to appear under each tab icon
onRelease = showScreen --function to execute when pressed
}
mainView:insert(tabBar)
loadScreen(“screen1”)
tabBar.selected()
else
tabBar = viewController.newTabBar{
background = “gfx/tabBar.png”, --tab bar background
tabs = {“Hem”, “Regler”, “Rapportera”, “Topplista”}, --names to appear under each tab icon
onRelease = showScreen --function to execute when pressed
}
mainView:insert(tabBar)
print (“tabbar loaded”)
print ("user id " … “” … “is present so load screen 3 and set that as active tab”)
loadScreen(“screen3”)
tabBar.selected()
end
end[/lua]
As you can see I am opening a textfile and checks if the userID value is 0 (zero) and if it is the logged has never been logged in before in the app so I only want to show to tabs to them.
But if they have logged in and that routine saves the userid in a textfile there are more tabs to show.
I can’t seem to manage to reload the tabs from another sceene.lua file or in anyway reload it inside the app after it has been created.
Any help is greatly appreciated.
[import]uid: 22737 topic_id: 10359 reply_id: 310359[/import]