C.Johns C.Johns - 8 months ago 68
iOS Question

Assertion failure while trying to pop views from the navigation stack

I'm trying to pop to a specific view controller that is in the navigation stack but I am doing something wrong as I am getting this error pop up when I try to execute the code

Assertion failure in -[UINavigationController popToViewController:transition:], /SourceCache/UIKit_Sim/UIKit-1912.3/UINavigationController.m:2229

Here is the code thats causing the issue

FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController.xib" bundle:nil];

[self.navigationController popToViewController:firstViewController animated:YES];


Managed to find an example else where which works perfectly.

//Just choose objectAtIndex number to pop to a particulart point on the navigation stack

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

Hope this helps.