【发布时间】:2016-12-18 01:05:45
【问题描述】:
所以我一直在承担学习 Swift 和 XCode 界面以进入 iOS 开发的任务。为此,我一直在练习一些项目,这些项目可以帮助我了解这一切,所以我选择了一个制作自定义键盘的项目。但是,由于我猜这些教程是用旧版本的 Swift/XCode 编写的,所以我不断收到错误,尤其是一个。
每当我进入设置并添加我的自定义键盘时,我都会去使用它,每当我在键盘切换器中切换它时,键盘就会崩溃并默认恢复为原始 iOS 键盘(模拟器和我的手机都会发生这种情况.另外,目标iOS是正确的)。在那次崩溃后,我收到了这个错误:
plugin CalculatorKeyboard plugin myName.CalculatorKeyboard.Calculator interrupted
plugin CalculatorKeyboard plugin myName.CalculatorKeyboard.Calculator invalidated
我正在使用的当前代码:
class KeyboardViewController: UIInputViewController {
var customInterface: UIView!
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
let nib = UINib(nibName: "Calculator", bundle: nil)
let objects = nib.instantiateWithOwner(self, options: nil)
customInterface = objects[0] as! UIView
}
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(customInterface)
}
}
旧代码:
// var customInterface: UIView!
override func viewDidLoad() {
super.viewDidLoad()
loadInterface()
}
func loadInterface() {
let calculatorNib = UINib(nibName: "Calculator", bundle: nil)
let objects = calculatorNib.instantiateWithOwner(self, options: nil)
view = objects[0] as! UIView
}
我希望我能在这方面得到一些帮助,因为我无法在 Google 上找到任何答案。谢谢! :)
注意:如果我可以使用旧代码,我会更喜欢,因为它在自己的功能中更简洁。
【问题讨论】: