ios - 在 Appdelegate 中设置 RootViewController

标签 ios iphone swift storyboard

我的应用程序中有 Storyboard,但我不想在info.plist 中设置Main storyboard file base name,以及我不想为任何 View Controller 场景设置入口点,即 Is Initial View Controller in storyboard

虽然我想用 Storyboard 中的一些场景启动应用程序,但所有显示给我的都是黑屏。

当我尝试过

let testob:testClass = testClass()
self.window?.rootViewController = testob

在 AppDelegate 中,它没有工作并且出现了同样的黑屏。

但是当我在 info.plist 中设置 Main storyboard file base name 时, Storyboard中的入口点即 Is Initial View Controller 一切正常。

有什么解决办法吗?

最佳答案

您需要实例化窗口并使其成为关键且可见。

let bounds = UIScreen.main.bounds
self.window = UIWindow(frame: bounds)
self.window?.rootViewController = rootViewController
self.window?.makeKeyAndVisible()

关于ios - 在 Appdelegate 中设置 RootViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36081864/

相关文章:

android - phonegap开发环境

iphone - 我应该保存哪些私钥才能重建我的 iOS 应用程序?

ios - 简单的演示接近事件 iOS 应用程序不工作(Estimote 信标)

iphone - 从右到左 UINavigationController

ios - 如何实现这种风格的 UITextField

ios - 像 Uber iOS 应用程序一样在 Google map 上移动标记?

iphone - iPhone 上的编译器优化和 UIView 框架

ios - 不同地区的 NSNumberFormatter

ios - 更改 Nav 的 rootViewController 会导致 UISplitViewController 在紧凑纵向方向上显示详细信息

ios - 无法完全关闭我以前的 alertcontroller