Swift 2.0 在 AppDelegate 之前声明 UINavigationController
Swift 2.0 Declaring UINavigationController before AppDelegate
在我的应用程序中,我在我的应用程序委托 class 之前声明了我的导航控制器,它在 ios7 和 iOS 8 上运行良好。但是一旦到了升级到iOS 9和Xcode 7,好像不想工作。
当我的导航控制器在我的应用委托 class 之前声明时,如下所示:
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 以不允许这样做?我该如何继续这样使用我的导航控制器?
我不太清楚为什么要解决这个问题,我只需要在应用程序 Delegate
中删除 UINavigationControllerDelegate
在我的应用程序中,我在我的应用程序委托 class 之前声明了我的导航控制器,它在 ios7 和 iOS 8 上运行良好。但是一旦到了升级到iOS 9和Xcode 7,好像不想工作。
当我的导航控制器在我的应用委托 class 之前声明时,如下所示:
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 以不允许这样做?我该如何继续这样使用我的导航控制器?
我不太清楚为什么要解决这个问题,我只需要在应用程序 Delegate
中删除UINavigationControllerDelegate