我正在为iOS8玩游戏,当我创建一个扩展 UIView
的新类时,我在加载键盘时出现 Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP,subcode=0x0)
错误 . 错误显示在 class KeyButton: UIView {
行上,我正在努力进一步调试 . 我原本试图扩展 UIButton
但是没有用,所以我把它改成了 UIView
而没有进一步的运气 .
我知道Swift / iOS8会有一些问题,但希望这是可以解决的!
Edit
全班代码:
import UIKit
class KeyButton: UIView { /* This is where the app crashes, apparently */
init(frame: CGRect) {
super.init(frame: frame)
// Initialization code
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func drawRect(rect: CGRect)
{
// Drawing code
}
*/
}
1 回答
我最近遇到了类似的问题,但想出来了 . 事实证明,在iOS 8中,但不是iOS 7,需要
initWithCoder
(在Objective-C中) . 您所要做的就是将以下内容添加到您的 class :我希望有所帮助!