Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Tried to pop to a view controller that doesn't exist.'

I am getting this error when I call my method dismissView. Here is the method stub:

-(IBAction)dismissView
{
    RootViewController *rootController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
    [self.navigationController popToViewController:rootController animated:YES];
}

That should work, and I've checked, rootController is initialized and allocated. Any ideas?

like image 452
skylerl Avatar asked Feb 01 '10 20:02

skylerl


People also ask

How do I find the view controller?

If you need to find the view controller that is responsible for a particular view, the easiest thing to do is walk the responder chain. This chain is built into all iOS apps, and lets you walk from one view up to its parent view, its grandparent view, and so on, until it reaches a view controller.

How do I go back to the previous view controller in iOS 4?

Open your storyboard where your different viewController are located. Tap the viewController you would like your navigation controller to start from. On the top of Xcode, tap "Editor" -> Tap embed in.

What does pop view controller do?

Pushes a view controller onto the receiver's stack and updates the display. func popToRootViewController(animated: Bool) -> [UIViewController]? Pops all the view controllers on the stack except the root view controller and updates the display.


1 Answers

I had this problem recently and solved with something like this...

[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
like image 183
Joao Henrique Avatar answered Sep 28 '22 00:09

Joao Henrique