I'm having a very strange problem with the UINavigationController.
I found a very similar question here:
http://stackoverflow.com/questions/1542040/uinavigationcontroller-not-popping-uinavigationbar-items
but the solution there had to do with the fact that the guy had added a category to NSMutableArray, and I'm not doing anything like that.
In short, the problem is this: I have a navigation controller and I'm pushing a few view controllers on it. Then when the 'back' button is tapped the view controller is popped, but the corresponding navigation item isn't. If I tap back again, then the navigation item is popped.
Besides, it only happens when using the back button from the navigation controller's navigation bar. If I call popViewController explicitly (for example from a button press), it works as expected.
And this only happens on my iPad running OS 3.2, but not on my iPod Touch running OS 3.0 or on the simulator.
I've been trying to isolate the problem in a separate project from the rest of my app so I can experiment with it, but I can't get it to reproduce, though it occurs 100% of the times on specific views in my app.
I know that's not nearly enough information to get an specific answer, but I just wanted to know if anyone ever heard of a navigation controller not popping the navigation items as expected, just so I could have some clue as to where to investigate next.
Here's an example of the code I use to push a view controller, it's pretty straightforward, I'm not trying to do anything special with it:
// pushing a view controller from a button press (set up with interface builder)
- (IBAction) tappedExtras
{
ExtrasViewController *controller = [[ExtrasViewController alloc] initWithNibName:@"ExtrasViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:YES];
[controller release];
}
note: in that example I'm using a custom view controller class called ExtrasViewController, but the problem happened with any kind of view controller I tried.
And here's a bit of code used to pop the view controller explicitly, also triggered by a button press set up with interface builder:
- (IBAction) cancelChanges
{
userCancelled = YES;
[self.navigationController popViewControllerAnimated:YES];
}
this works perfectly (popping the view controller explicitly), but on the exact same view controller if instead of tapping the button set up with interface builder you tap the back button on the navigation bar, the navigation item is not popped correctly.