[英]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): 我像这样(通过
AppDelegate
的application
方法下的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.