C.Johns C.Johns - 1 year ago 121
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];

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download