简体   繁体   English

我还需要设置入口点吗? (初始视图控制器)

[英]Do I still need to set the entry point? (Initial view controller)

I'm setting the rootViewController of the window programatically, like this ( didFinishLaunchingWithOptions under AppDelegate 's application method): 我像这样(通过AppDelegateapplication方法下的didFinishLaunchingWithOptions以编程方式设置窗口的rootViewController:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let rootViewController = storyboard.instantiateViewControllerWithIdentifier("loginScreen")

window = UIWindow(frame: UIScreen.mainScreen().bounds)
window?.makeKeyAndVisible()

if let window = window {
    window.rootViewController = rootViewController
}

Am I still required to go in the Interface Builder and set that controller as initial view controller? 我仍然需要进入Interface Builder并将该控制器设置为初始视图控制器吗? I get Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set? Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set? If I set an entry point I have no problem and the error disappears. 如果我设置一个入口点,我没有问题,错误消失了。 I want to know what is the correct way of programatically loading views. 我想知道以编程方式加载视图的正确方法是什么。 It's weird to set the rootViewController both programatically and by interface builder. 既通过编程方式又通过接口构建器设置rootViewController很奇怪。 Note that I am a beginner. 请注意,我是一个初学者。

Please check the tick mark 'Is Initial View Controller' in controller properties, And then clean and run. 请在控制器属性中选中“是Initial View Controller”标记,然后清理并运行。 If still exists, please try this 如果仍然存在,请尝试此

   UIApplication.sharedApplication().keyWindow?.rootViewController = viewController;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS-如何在我的应用启动时将另一个视图控制器设置为我的初始视图控制器? - iOS - How do I set another view controller to be my initial view controller when my app starts? 如何检查视图控制器是否为初始视图控制器? (SWIFT 3) - How do I check if view controller is initial view controller? (SWIFT 3) 指定故事板的入口点(不是初始视图) - Specifying entry point for storyboard (not the initial view) 设置导航控制器的初始视图控制器 - Set initial view controller of a navigation controller 如何使用PFUser更改初始视图控制器? - How do I change the initial view controller with a PFUser? 无法为 UIMainStoryboardFile 'Main' 实例化默认视图 controller - 也许未设置指定的入口点? - Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set? 未能为 UIMainStoryboardFile 'Main' 实例化默认视图 controller - 也许未设置指定的入口点? - Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set? 拆分视图控制器 - 将表视图设置为初始视图控制器 - Split view controller - set table view as the initial view controller 如何使用委托来指示哪个视图控制器行为与初始视图控制器相同? - How do I use the delegate to dictate which view controller behaves as the initial view controller? 如何根据条件设置初始视图控制器? - How to set initial view controller based on conditions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM