删除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
}