This is didFinishLaunchingWithOptions Method in AppDelegate. Let me explain scenario, I have developed sideMenu like facebook in my app, but now I have to change the sideMenu li
Knowledge Sharing Using Swift:
Changing root view controller from class other than app delegate.swift
let appdelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var homeViewController = mainStoryboard.instantiateViewControllerWithIdentifier("HomeViewController") as! HomeViewController
let nav = UINavigationController(rootViewController: homeViewController)
appdelegate.window!.rootViewController = nav
Changing rootviewcontroller With Animation can be achieve with:
UIView.transitionWithView(self.window!, duration: 0.5, options: UIViewAnimationOptions.TransitionFlipFromLeft, animations: {
self.window?.rootViewController = anyViewController
}, completion: nil)
We can write generalise method too similar to this.
Hope this will helpful for someone.