嵌入式导航控制器到XIB文件的导航为零

时间:2019-12-17 15:29:53

标签: swift xcode

我尝试将导航控制器添加到swift 5的xib文件中,然后尝试推送到其他视图控制器,但导航控制器已经为零。有人知道吗,请帮助谢谢

在应用程序委托中

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    window = UIWindow(frame: UIScreen.main.bounds)
    let mainController = HistoryViewController() as UIViewController
    let navigationController = UINavigationController(rootViewController: mainController)
    navigationController.navigationBar.isTranslucent = false
    self.window?.rootViewController = navigationController
    self.window?.makeKeyAndVisible()
    return true

}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    print(self.navigationController)

    let vc = HistoryDetailViewController()
    self.navigationController?.pushViewController(vc, animated: true)
}

0 个答案:

没有答案