Can't get the tabBar to work - help!

What am I doing wrong here? I followed the tutorial for using images and no labels. I am getting a Attempt to index a nill value line 82 which is at the bracket right after local tabBar = widget.newTabBar. This is my first time using the tabBar.

Thanks!

Warren

---------------------------------------------------------------------------------- -- -- scenetemplate.lua -- ---------------------------------------------------------------------------------- local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local widget = require( "widget" ) local function onPress( event )    local pressedTab = event.target    print( pressedTab.\_id.." pressed!" ) end local tabButtons = {    {       id = "Tab1",       width = 48,       height = 48,       defaultFile = "images\homered.png",       overFile = "images\homered.png",       onPress = onPress,       selected = true    },    {       id = "Tab2",       width = 48,       height = 48,       defaultFile = "images\nightlifewhite.png",       overFile = "images\nightlifered.png",       onPress = onPress,       selected = false    },    {       id = "Tab3",       width = 48,       height = 48,       defaultFile = "images\eventswhite.png",       overFile = "images\eventsred.png",       onPress = onPress,       selected = false    },    {       id = "Tab4",       width = 48,       height = 48,       defaultFile = "images\culturewhite.png",       overFile = "images\culturered.png",       onPress = onPress,       selected = false    },    {       id = "Tab5",       width = 48,       height = 48,       defaultFile = "images\searchwhite.png",       overFile = "images\searchred.png",       onPress = onPress,       selected = false    },    {       id = "Tab6",       width = 48,       height = 48,       defaultFile = "images\contactwhite.png",       overFile = "images\contactred.png",       onPress = onPress,       selected = false    } } function scene:createScene( event )     local group = self.view local tabBar = widget.newTabBar     {    left = 0,    top = display.contentHeight - 60,    width = 300,    height = 48,     backgroundFile = "images\tab.png",     tabSelectedLeftFile = "images\tab.png",     tabSelectedRightFile = "images\tab.png",     tabSelectedMiddleFile = "images\tab.png",     tabSelectedFrameWidth = 48,     tabSelectedFrameHeight = 48,    buttons = tabButtons } end -- Called immediately after scene has moved onscreen: function scene:enterScene( event )     local group = self.view           end -- Called when scene is about to move offscreen: function scene:exitScene( event )     local group = self.view           end -- Called prior to the removal of scene's "view" (display group) function scene:destroyScene( event )     local group = self.view      end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- "createScene" event is dispatched if scene's view does not exist scene:addEventListener( "createScene", scene ) -- "enterScene" event is dispatched whenever scene transition has finished scene:addEventListener( "enterScene", scene ) -- "exitScene" event is dispatched before next scene's transition begins scene:addEventListener( "exitScene", scene ) -- "destroyScene" event is dispatched before view is unloaded, which can be -- automatically unloaded in low memory situations, or explicitly via a call to -- storyboard.purgeScene() or storyboard.removeScene(). scene:addEventListener( "destroyScene", scene ) --------------------------------------------------------------------------------- return scene

In each your button definition area can you try putting in a label="", and see what happens? So your first button def would look like the following : 

local tabButtons = { { id = "Tab1", width = 48, height = 48, label = "", defaultFile = "images\homered.png", overFile = "images\homered.png", onPress = onPress, selected = true },

Please put the label="", in each button and lets see if that solves the problem.

I just tried and same error. I thought of that before but saw it was optional according to the docs. Nut sure what could be nil but its driving me crazy!

Thanks

I loaded the code from the tutorial with no images and it worked fine. I put images in one tab and it failed. Anyone know why?

Got it! Sorry for missing this earlier. Your slashes are pointing the wrong way in your image file path… They should be like : 

“images/homered.png”,

rather than 

“images\homered.png”,

which you have now. Hope this helps.

I wish that was it but it is not. I had put the images in the same folder rather than the images folder and just had the images name there and still same issue. I am going to copy all of the code and images from their business demo online that works for me and then make changes till I have mine working. Unless you or someone sees what it is. Its probably something stupid I am missing!!

Warren

Can you try 

width = display.contentWidth,

rather than width = 300, 

I don’t think CL tabBar implementation supports tabBar covering less than the width of your display. Maybe thats it. 

That wasn’t it either. The text demo was set to 240 and worked. I changed it anyways and fails with an image in the tab. The tab bar is drawing but fails before it draws the tabs.

how about just trying to use the Corona Labs logo from Business Sample App. Just to rule out if anything is wrong with your images. Lets see if your code with CL icon works as is. Then its a matter of troubleshooting your image files. 

In each your button definition area can you try putting in a label="", and see what happens? So your first button def would look like the following : 

local tabButtons = { { id = "Tab1", width = 48, height = 48, label = "", defaultFile = "images\homered.png", overFile = "images\homered.png", onPress = onPress, selected = true },

Please put the label="", in each button and lets see if that solves the problem.

I just tried and same error. I thought of that before but saw it was optional according to the docs. Nut sure what could be nil but its driving me crazy!

Thanks

I loaded the code from the tutorial with no images and it worked fine. I put images in one tab and it failed. Anyone know why?

Got it! Sorry for missing this earlier. Your slashes are pointing the wrong way in your image file path… They should be like : 

“images/homered.png”,

rather than 

“images\homered.png”,

which you have now. Hope this helps.

I wish that was it but it is not. I had put the images in the same folder rather than the images folder and just had the images name there and still same issue. I am going to copy all of the code and images from their business demo online that works for me and then make changes till I have mine working. Unless you or someone sees what it is. Its probably something stupid I am missing!!

Warren

Can you try 

width = display.contentWidth,

rather than width = 300, 

I don’t think CL tabBar implementation supports tabBar covering less than the width of your display. Maybe thats it. 

That wasn’t it either. The text demo was set to 240 and worked. I changed it anyways and fails with an image in the tab. The tab bar is drawing but fails before it draws the tabs.

how about just trying to use the Corona Labs logo from Business Sample App. Just to rule out if anything is wrong with your images. Lets see if your code with CL icon works as is. Then its a matter of troubleshooting your image files.