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

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

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

The -popToViewController is used to pop view controllers OFF the stack, down to one that already exists. Your UINavigationController has a stack of ViewControllers (stored in the viewControllers property), when you popToViewController, you're going to want to pass one of the elements in that array as the first argument.

What you most likely want to do in this case is use -popViewControllerAnimated:, which will remove the top ViewController from the stack


I resolved this by using pushViewController rather than popToViewController