【问题标题】:Swift 2.0 Declaring UINavigationController before AppDelegateSwift 2.0 在 AppDelegate 之前声明 UINavigationController
【发布时间】:2015-09-14 14:37:31
【问题描述】:

在我的应用程序中,我声明了我的导航控制器 在我的应用程序委托类之前,它在 ios7 和 iOS 8 上运行良好。但是一旦升级到 iOS 9 和 Xcode 7,它似乎不想工作。

当我的导航控制器在我的应用委托类之前声明时,如下所示:

var navigationController = UINavigationController()

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UINavigationControllerDelegate, CLLocationManagerDelegate {

它不允许我在我的应用程序中访问我的导航控制器确实完成了启动功能:

    self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
    let rootViewController: ViewController = ViewController()
    navigationController = UINavigationController(rootViewController: rootViewController)
    navigationController.setNavigationBarHidden(true, animated: false)
    navigationController.view.layer.cornerRadius = 8
    navigationController.view.layer.masksToBounds = true
    //navigationController.shouldAutomaticallyForwardRotationMethods()
    window!.rootViewController = navigationController
    window!.makeKeyAndVisible()

难倒我的是我可以毫无问题地在任何其他视图中调用我的导航控制器。在 Xcode 7、iOS 9 和 swift 2 之前,这也可以正常工作。

有什么东西改变为 swift 不允许这样做吗?我该如何继续这样使用我的导航控制器?

【问题讨论】:

    标签: xcode uinavigationcontroller swift2 ios9 xcode7


    【解决方案1】:

    我不太清楚为什么,但要解决这个问题,我所要做的就是在应用程序代表中取出 UINavigationControllerDelegate

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-28
      • 1970-01-01
      相关资源
      最近更新 更多