自定义UINavigationController init导致使用未实现的初始化程序'init(nibName:bundle :)

时间:2017-11-06 11:25:34

标签: ios swift uinavigationcontroller

我有这些自定义类:

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 :)'

我不明白为什么要打电话给它......那该怎么办?

0 个答案:

没有答案