Reputation:
Is there any way to redirect (push or perform segue etc.) to initial view controller aka rootViewController from appdelegate
class? I am using stroryboard
btw.
Any answers are appreciated.
UP. I am not using navigation controller.
Upvotes: 2
Views: 1097
Reputation: 47
By Using Swift 4.2
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let window: UIWindow? = (UIApplication.shared.delegate?.window)!
window?.rootViewController = mainStoryboard.instantiateInitialViewController()
Working Perfect...
Upvotes: 0
Reputation: 116
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
window.rootViewController = [storyboard instantiateInitialViewController];
Upvotes: 3
Reputation: 134
UINavigationController popToRootViewController methods takes you there, if you're using UINav controller.
Other way you can try out: self.window.rootViewController is a reference that might useful.
Upvotes: 0
Reputation: 16276
I suggest nesting all your navigation stack under a UINavigationController
, then it would be as easy as invoking the popToRootViewControllerAnimated:
method.
Upvotes: 0