[英]how can I set initial viewController that can push after instantiate in swift 5
I can't push from initial viewController after using this code使用此代码后,我无法从初始 viewController 推送
self.window = UIWindow(frame: UIScreen.main.bounds) self.window = UIWindow(框架:UIScreen.main.bounds)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = storyboard.instantiateViewController(withIdentifier: Identifier)
self.window?.rootViewController = initialViewController
self.window?.makeKeyAndVisible()
You have to Embed UIViewController in a UINavigationController.您必须在 UINavigationController 中嵌入 UIViewController。 Try this one:
试试这个:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = storyboard.instantiateViewController(withIdentifier: Identifier)
let navController = UINavigationController(rootViewController: initialViewController)
self.window?.rootViewController = navController
self.window?.makeKeyAndVisible()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.