Corona tabBar 创建失败。

在我的menu.lua中,我有以下代码:storyboard.gotoScene(“vegScreen”),意思是:蔬菜屏幕/菜单。

在我的vegScreen.lua文件的scene:createScene函数中,我尝试创建一个有两个选项卡的tabBar。使用以下代码:

local tabButtons = {
    {
        width = 50, height = 40,
        defaultFile = "assets/tabIcon.png",
        overFile = "assets/tabIcon-down.png",
        label = "Per catagory",
        onPress = function() storyboard.gotoScene( "catagory" ); end,
        selected = true
    },
    {
        width = 50, height = 40,
        defaultFile = "assets/tabIcon.png",
        overFile = "assets/tabIcon-down.png",
        label = "All products",
        onPress = function() storyboard.gotoScene( "all" ); end,
    }
}

productBar = widget.newTabBar{  -- line 82
    top = 65,
    width = display.contentWidth,
    backgroundFile = "assets/tabBar_background.png",
    tabSelectedLeftFile = "assets/tabBar_background.png",
    tabSelectedMiddleFile = "assets/tabBar_background.png",
    tabSelectedRightFile = "assets/tabBar_background.png",
    tabSelectedFrameWidth = 20,
    tabSelectedFrameHeight = 52,
    buttons = tabButtons
}

group:insert(productBar)

使用此代码,我会出现以下错误:

http://i.imgur.com/0koV4PK.png

vegScreen.lua中的第82行是我创建新的tabBar时(productBar = widget.newTabBar)

虽然我不知道我创建的图像是否被正确使用,但它应该给我显示什么吧?我在vegScreen.lua文件的顶部有模块要求声明(用于storyboard和widget),创建了位于与vegScreen.lua相同文件夹中的catagory.lua和all.lua文件,并定义了group变量。有人能帮助我吗?这个错误对我来说毫无意义。

点赞
用户3416676
用户3416676

不是非常正式的回答,但是我解决了我的问题。我创建了一些文件,使用代码加载内容。我认为问题在于无法向现有的钛视图中添加内容。

所以我删除了那些文件,并通过代码创建了视图,这非常有效。

2014-10-28 18:51:06