(iOS) How to segue back to a UIViewController thats already loaded?

Assuming by your use of " push " you mean that you are using a UINavigationController then you can use the following to return to the top of the stack.

Up vote 0 down vote favorite share g+ share fb share tw.

I have a view on a storyboard the has a button to perform a certain action. To perform this action though, the user must be logged in. The button handler tests if the user is logged in and performs one segue if YES and another if NO.

The NO segues pushes to a login view controller. There is another segue connecting back to the first view controller so if login is successfull the user can pick up where they left off. The view controllers are embedded in a navigation controller.

Problem is, the 'return' segue is loading a whole new instance of the view controller and not referencing the origional instance so I end up with empty interface elements and 2 copies of that view controller in memory. How can I get back to the origional instance of the view controller? Objective-c ios storyboard segue link|improve this question edited Apr 4 at 3:48 asked Apr 4 at 0:58TijuanaKez436 89% accept rate.

Assuming by your use of "push" you mean that you are using a UINavigationController, then you can use the following to return to the top of the stack. Self. NavigationController popViewControllerAnimated:YES; or UIViewController *prevVC = self.

NavigationController. ViewControllers objectAtIndex:; self. NavigationController popToViewController:prevVC animated:YES; to pop to a specific level where is the level.

Related Questions