【发布时间】:2017-11-09 12:21:12
【问题描述】:
我需要在AppDelegate中访问UINavigationController
这是我尝试过的
func applicationDidBecomeActive(_ application: UIApplication) {
let syncManager = SyncManager()
let navigationController: UINavigationController = UIStoryboard(
name: "Main",
bundle: nil
).instantiateViewController(withIdentifier: "MainNavigationController") as! UINavigationController
syncManager.setNavigationController(navigationController)
syncManager.sync()
}
这似乎不起作用。
如何从AppDelegate 访问UINavigationController?
谢谢。
更新
当应用程序处于活动状态时,我正在使用此 library 在应用程序中显示通知。这个库需要一个 navigationController 的实例来显示通知。
当我在AppDelegate 中使用此代码时,不会显示通知,但是当我在ViewController 中使用时,会显示通知。
【问题讨论】:
-
有错误提示吗?
-
没有错误信息,但也不能正常工作。基本上我正在使用需要 navigaitonController 实例的通知显示。当我使用此代码时,通知根本不显示。但是当我直接使用 viewController 中的 navigaitonController 实例时,它可以工作。让我更清楚地更新我的问题。
-
一个标准的
UINavigationController实际上没有UIViewController。它只能导航和管理他们的viewControllers。 -
UIWindow的rootViewController不适合您吗?您的视图层次结构如何?
标签: swift swift3 uinavigationcontroller appdelegate