lua - xCode Simulator 中的 Corona 应用程序的紫色背景

标签 lua ios-simulator coronasdk

我有一个 Corona 应用程序,带有两个 Storyboard场景(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

这是怎么回事?

最佳答案

答案就在这里,伙计们:native.textField

关于lua - xCode Simulator 中的 Corona 应用程序的紫色背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21106253/

相关文章:

coronasdk - 在 Corona SDK 中,是否可以将场景用于部分覆盖另一个 View 的 View

web - 如何在 OpenWRT/uhttpd 上从 Lua 读取 POST

ios - 模拟器旋转锁定

iphone - Corona LUA 和 OOP 设计

ios - 需要模拟器不提供的硬件的应用程序的 iTunes App store 屏幕截图

iphone - 无法在 Ipad 中启动应用程序

coronasdk - 如何在corona sdk中设置字体阴影

function - 通过引用调用Lua函数

C++将字符串传递给lua错误

io - 获取Lua中2条特定行之间的行