您的位置:首页 > 移动开发

'Application windows are expected to have a root view controller at the end of application launch' [

2017-08-29 11:41 459 查看
删除Main.storyboard和launchboard.storyboard之后,将General ——》Deployment Info ——》Main Interface设置为空

在didFinishLaunchingWithOptions中添加以下代码后启动模拟器出现'Application windows are expected to have a root view controller at the end of application launch'异常

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.

self.window = UIWindow(frame: UIScreen.mainScreen().bounds);
self.window?.backgroundColor = UIColor.redColor();
self.window?.makeKeyAndVisible();
解决办法是:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.

self.window = UIWindow(frame: UIScreen.mainScreen().bounds);
self.window?.backgroundColor = UIColor.redColor();
self.window?.makeKeyAndVisible();
let rootViewController = UIViewController() as UIViewController;
let navigationController = UINavigationController(rootViewController: rootViewController) as UINavigationController;
self.window?.rootViewController = rootViewController;
self.window?.addSubview(navigationController.view);
return true
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐