【发布时间】:2018-12-01 03:59:08
【问题描述】:
我试图让我的登录页面从AppDelegate.swift 的初始视图控制器上弹出,我正在使用let authVC = storybaord.instantiateViewController(withIdentifier: "StartVC")
实例化它。但是,视图控制器链接到导航控制器,当我使用代码时,当我单击视图控制器的按钮时,它会使应用程序崩溃。代码:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
if Auth.auth().currentUser == nil {
let storybaord = UIStoryboard(name: "Main", bundle: Bundle.main)
let authVC = storybaord.instantiateViewController(withIdentifier: "StartVC")
window?.makeKeyAndVisible()
window?.rootViewController?.present(authVC, animated: false, completion: nil)
}
return true
}
在Main.Storyboard 文件中,我在导航控制器的第一个视图控制器上有故事板 ID ("StartVC")。截图:http://prntscr.com/lp8fez |
http://prntscr.com/lp8flq
以下是崩溃日志:
Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'toName'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.
【问题讨论】:
-
"它使应用程序崩溃" 然后向我们展示崩溃日志。
-
我认为你不能在启动时展示任何控制器!
-
我编辑了帖子并添加了崩溃日志。
标签: ios swift storyboard