Not sure if you already resolved this but I'm facing the same issue but with one difference. The navigation stack only messes up if I setAnimated to NO.
So this works:
[self.navigationController setNavigationBarHidden:YES animated:YES];
...
[self.navigationController setNavigationBarHidden:NO animated:YES];
but this doesn't:
[self.navigationController setNavigationBarHidden:YES animated:NO];
...
[self.navigationController setNavigationBarHidden:NO animated:NO];
If you really want animated to be NO for whatever reason, one work around is to set alpha to 0/1 instead of hiding/unhiding the NavigationBar:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.navigationBar.alpha = 0.0f;
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController.navigationBar setAlpha:1.0f];
}
The downside is that there's no nice slide-to-pop transition animation. If you did find a better way, do let us know.
UPDATE: This is now old but I solved my issue by not ensuring that whatever state is changed in current view's viewWillDisappear, is restored in viewWillAppear. Don't tear down things in viewWillDisappear that you can't setup again.
This is what happens when you cancel the pop animation:
- Current viewWillDisappear
- New viewWillAppear
- [cancelled... reverses]
- New viewWillDisappear
- New viewDidDisappear
- Current viewWillAppear
- Current viewDidAppear
I guess in this brave new world, viewWillDisappear/viewWillAppear does not always mean view "will" disappear/appear :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…