我决定继续使用Swift完成剩余的项目。当我将自定义类(UIViewcontroller
的子类)添加到我的storyboard视图控制器并加载项目时,应用程序突然崩溃,并显示以下错误:
致命错误:对于类而言,未实现初始化程序'init(coder:)'的使用
这是代码:
import UIKit
class TestViewController: UIViewController {
init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
// Custom initialization
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// #pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue?, sender: AnyObject?) {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
}
请提出建议
self.viewController = view self.imageName = "" self.actionName = "" super.init(frame: frame) }
- scrainiefatalError("init(coder:) has not been implemented")
这行代码使我的应用程序停止了。 - Jose Manuel Abarca Rodríguez