【发布时间】:2019-10-30 16:51:28
【问题描述】:
如何在 swift5 中从 appdelegate 或 scenedelegate 呈现视图控制器? 我试过这个但没有用:
self.window = UIWindow(frame: UIScreen.main.bounds)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = storyboard.instantiateViewController(withIdentifier: "profile")
self.window?.rootViewController = initialViewController
self.window?.makeKeyAndVisible()
【问题讨论】:
-
但是如果您使用的是故事板,为什么要添加代码来显示它?无需代码即可在应用启动时自动显示主故事板。
-
“没有用”是什么意思?错误信息是什么?
-
不,我想以编程方式从 appdelegate 或 scenedelegate 呈现视图控制器。 @rmaddy
标签: swift viewcontroller