Dear Corona community,
what I’d like to do:
Create a tabbar with images located in DocumentsDirectory as tabButtons
My code:
-- set fallback button local profileButton = { width = 25, height = 25, defaultFile = "menuHeart.png", overFile = "menuHeartFilled.png", onPress = function() composer.gotoScene("newsfeed") end } -- if profilepicture exists on device, use it as a tabButton local path = system.pathForFile( "profilepicture.jpg", system.DocumentsDirectory) local fhd = io.open( path ) if(fhd) then fhd:close() profileButton = { width = 25, height = 25, defaultFile = "profilepicture.jpg", overFile = "profilepicture.jpg", baseDir = system.DocumentsDirectory, onPress = function() composer.gotoScene("newsfeed") end } end -- create menu options local tabButtons = { { width = 25, height = 25, defaultFile = "home.png", overFile = "home-filled.png", selected = true, onPress = function() composer.gotoScene("dofaver") end }, { width = 25, height = 25, defaultFile = "add.png", overFile = "add-filled.png", onPress = function() composer.gotoScene("addFirst") end }, profileButton, { width = 25, height = 25, defaultFile = "profile.png", overFile = "profile-filled.png", onPress = function() composer.gotoScene("friends") end }, { width = 25, height = 25, defaultFile = "settings.png", overFile = "settings-filled.png", onPress = function() composer.gotoScene("setAccount") end } } tabBar = widget.newTabBar( { height = 50, top = display.actualContentHeight + display.screenOriginY - 50, x = screenOriginX, buttons = tabButtons, backgroundFile = "tabbarTransparent.png", tabSelectedLeftFile = "tabbarTransparent.png", tabSelectedMiddleFile = "tabbarTransparent.png", tabSelectedRightFile = "tabbarTransparent.png", tabSelectedFrameWidth = 0, tabSelectedFrameHeight = 0 } )
Does this work?
No, I get a “The defaultFile passed for tab 3 does not exist” error, even though fileCheck returns true. When I don’t have the profilepicture.jpg in DocumentsDirectory, fileCheck returns - of course - false and I get the fallback-button no problem.
Any ideas?
Thanks