Reputation: 2268
the view controller that is pushed onto the stack cannot be an instance of tab bar controller and it must not already be on the navigation stack.
I want to know how could I discover if the view controller that I'm about to push onto the stack is already in stack.
Upvotes: 1
Views: 2391
Reputation: 12405
Try this and let me know if it works.
for (UIViewController* controller in [self.navigationController viewControllers]) {
if ([controller isKindOfClass:[MapViewViewController class]])
{
NSLog(@"Cool");
}
}
Upvotes: 3
Reputation: 4835
are you looking for
[self.navigationController popToViewController:controller animated:YES];
Use the self.navigationController.viewControllers
array to reference the controller that's already on the nav controller's stack.
Upvotes: 1
Reputation: 920
You can use flags. Set a flag when you push the viewcontroller first time. Reset it if you pop to this view controller. Check the flag value before pushing. If set, it is already in stack, so don't push again. else, not in stack, so push it.
Upvotes: 0