I need to launch a view controller from the app delegate.
In the way you would perform a segue between view controllers.
I have an if statement that if true
Here's what you'd do if your rootViewController
did NOT inherit from UINavigationViewController
:
Basically you check what the currently presented tab is and then push from THAT view controller, rather than the rootViewController
that inherits from UITabBarController
.
let root = self.window?.rootViewController as UITabBarController
switch(root.selectedIndex){
case 0:
root.viewControllers?[0].pushViewController(viewController, animated: true)
break;
case 1:
root.viewControllers?[1].pushViewController(viewController, animated: true)
break
default:
println("Error presenting ViewController")
break;
}
My application has an initial/rootViewController that inherits from UITabBarController
, each of it's UITabBar
Relationship Controllers inherit from UINavigationController
, allowing me to pushViewController
from them.