我有这些自定义类:
1
class MyNavigationController: UINavigationController {
}
2
class HomeNavigationController: MyNavigationController {
init() {
super.init(rootViewController: HomeViewController())
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
3
class MyViewController: UIViewController {
}
4
class HomeViewController: MyViewController {
init() {
super.init(nibName: "HomeViewController", bundle: .main)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
然后我尝试在app delegate中初始化HomeNavigationController
的实例:
let homeVC = HomeNavigationController()
但是当这样做时,我收到了这个错误:
致命错误:对'HomeNavigationController'类使用未实现的初始化程序'init(nibName:bundle :)'
我不明白为什么要打电话给它......那该怎么办?