Corona app在xCode模拟器中的紫色背景

时间:2014-01-14 04:44:30

标签: lua ios-simulator corona

我有一个电晕应用,有两个故事板场景(scene1.luaaddDesire.lua)。

我将addDesire.lua显示为叠加层:

function onAddPurchase( event )
    if event.phase == "ended" then
        local options = {
            effect = "fromBottom",
            time = 500,
            isModal = true,
        }
        storyboard.showOverlay( "addDesire", options )
    end
end

在Corona Simulator中一切正常,但在xCode模拟器中,在几种情况下会出现粉红色背景。

1) addDesire.lua出现后onAddPurchase看起来像:

Incorrect pink background 1

什么时候看起来像:

Exptected background

2)当我关闭addDesire.lua(点击取消按钮)时会出现以下情况: Solid pink screen

引人注目的是甚至更奇怪

addDesire.lua有2个textFields和1个textBox,它是在function scene:createScene( event )中创建的。如果我注释掉创建这些对象的代码,一切都很完美。

function scene:createScene( event )
local group = self.view

local centerX = display.contentCenterX
local centerY = display.contentCenterY
local _W = display.contentWidth
local _H = display.contentHeight

local bg = display.newImageRect( "assets/dollar.png", 360, 570 )
bg:toBack()
bg.x, bg.y = _W/2, _H/2
bg:addEventListener( "tap", function() native.setKeyboardFocus(nil); end)
group:insert(bg)

-- Rounded Rect Alpha
roundedRect = display.newRoundedRect( 5, 5, _W*0.9, _H*0.8, 10 )
roundedRect.x, roundedRect.y = centerX, centerY
roundedRect:setFillColor( 0/255, 0/255, 0/255, 170/255 )
group:insert(roundedRect)
-- Label Title
titleLabel = display.newText( "Purchase", 0, 0, "AmericanTypewriter-Bold", 20 )
titleLabel.x, titleLabel.y = centerX, _H*0.15
group:insert(titleLabel)
-- Label Fam
nameLabel = display.newText( "Name", 0, 0, "AmericanTypewriter", 18 )
nameLabel.x, nameLabel.y = centerX, _H*0.20
group:insert(nameLabel)
-- Edit Fam
nameText = native.newTextField(_W/2, _H*0.26, 240, 30)
nameText.font = native.newFont(native.systemFont, 18)
nameText:addEventListener( "userInput", inputListener ) 
group:insert(nameText)
-- Label Name
descriptionLabel = display.newText( "Description", 0, 0, "AmericanTypewriter", 16 )
descriptionLabel.x, descriptionLabel.y = centerX, _H*0.31
group:insert(descriptionLabel)
-- Edit Name
descriptionText = native.newTextBox(_W/2, _H*0.44, 240, 100)
descriptionText.font = native.newFont(native.systemFont, 14)
descriptionText.isEditable = true
descriptionText:addEventListener( "userInput", inputListener ) 
group:insert(descriptionText)
-- Label Deposit
costLabel = display.newText( "Cost", 0, 0, "AmericanTypewriter", 16 )
costLabel.x, costLabel.y = centerX, _H*0.57
group:insert(costLabel)
-- Edit Deposit
costText = native.newTextField(_W/2, _H*0.64, 240, 30)
costText.font = native.newFont(native.systemFont, 18)
costText.inputType = "number"
costText.align = "center"
costText:addEventListener( "userInput", inputListener ) 
group:insert(costText)
-- Button Save & Start game
btnSave = widget.newButton {
    width = _W*0.4,
    height = 50,
    --defaultFile = "buttonDefault.png",
    --overFile = "buttonOver.png",
    label = "Buy",
    onEvent = onSaveData
}
btnSave.x, btnSave.y = _W/2, costLabel.y+150
group:insert(btnSave)
-- Button Cancel
btnCancel = widget.newButton {
    width = _W*0.8,
    height = 50,
    --defaultFile = "buttonDefault.png",
    --overFile = "buttonOver.png",
    label = "Cancel",
    onEvent = onExit,
}
btnCancel.x, btnCancel.y = _W/2, btnSave.y+50
group:insert(btnCancel)


end

发生了什么事?

1 个答案:

答案 0 :(得分:2)

答案就在这里:native.textField