我使用的是cocos2dx 3.2版本(不是quick版),lua代码创建的cc.EditBox,在这个cc.EditBox的回调函数editboxTest:registerScriptEditBoxHandler(editBoxTextEventHandle),其editBoxTextEventHandle函数实现如下:
local function editBoxTextEventHandle(strEventName,pSender)
local edit = pSender
local strFmt
if strEventName == “began” then
strFmt = string.format(“editBox %p DidBegin !”, edit )
print(strFmt)
elseif strEventName == “ended” then
strFmt = string.format(“editBox %p DidEnd !”, edit )
print(strFmt)
elseif strEventName == “return” then
strFmt = string.format(“editBox %p was returned !”, edit )
print(strFmt)
elseif strEventName == “changed” then
strFmt = string.format("editBox %p TextChanged, text: %s ", edit , edit:getText())
print(strFmt)
end
end
这个函数里面的print打印会导致 lua c stack overflow,从而使部分机型无法执行print后面的代码,iPhone5c(ios8.2)测试正常,iPhone6(ios8.3)测试不正常
解决方法:去掉strFmt = string.format(“editBox %p DidBegin !”, edit )中的%p格式符,改成strFmt = string.format(“editBox DidBegin !” ),反正不要打印带%p这种格式符的字符串。
注:cocos官方提供的cc.EditBox例子中就是用了%p,导致别人使用的时候直接复制过来,又没修改,因为在部分机型是正常的,所以出现潜在问题