If you are using a storyboard and want to programmatically configure rootViewController, first make sure the ViewController has a storyboard identifier in the identity inspector. Then in AppDelegate do the following:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let rootController = storyboard.instantiateViewControllerWithIdentifier("MyViewController") as! UIViewController
if let window = self.window {
window.rootViewController = rootController
}
return true
}
source
share