iOS 5 Storyboards - Returning to Initial View Controller
Asked Answered
R

1

6

I'm working on an application that uses the new Storyboard functionality in Xcode 4.2

Is there a way of programatically sending a user back to the initial view controller from any point within the application?

For example when a session expires and they need to login again (initial view controller is my login screen)

Rig answered 29/11, 2011 at 11:46 Comment(1)
Solved by: [[appDelegate.window rootViewController] dismissModalViewControllerAnimated:YES];Rig
P
3

I assume that you are using a UINavigationController. Then you can use the popToRootViewControllerAnimated: method. You should be able to do this with this line:

[self.navigationController popToRootViewControllerAnimated:NO]; // Put YES for animation.

You can read more about the UINavigationController in the docs.

Patency answered 29/11, 2011 at 12:32 Comment(2)
Its actually a mixture initially its a view controller and depending on types of account it can hit either a navigation controller and then into a tab controller. So you may be on a view, a tab or a table view. Ideally i'd like to be able to jump back to the initial view controller from any of these locationsRig
I see. Have you tried the popToViewController:animated: method? If you have a reference to your root view controller, this one might work.Patency

© 2022 - 2024 — McMap. All rights reserved.