iphoneobjective-cuiviewcontrolleruinavigationcontroller

'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?


Solution

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

    [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];