它说Could not find an overload for init that accepts the supplied arguments
class MyController: UIViewController {
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
convenience init() {
self.init(nibName: "CreditOptionsView", bundle: nil)
}
}
为什么呢? 它在XCode 6 beta 2中工作
答案 0 :(得分:3)
我解决它写一个空功能的覆盖,我不知道为什么swift无法找到它。例如:
class MyController: UIViewController {
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?){
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
convenience init() {
self.init(nibName: "CreditOptionsView", bundle: nil)
}
}
同样的事情发生在UINavigationController
的便利初始化中,并解决了再次添加空override
:
class MyNavigationController: UINavigationController {
override init(rootViewController: UIViewController) {
super.init(rootViewController: rootViewController)
}
convenience init() {
self.init(rootViewController: UIViewController())
}
}