问题
I found one that looks like iOS7 bug while popping view controllers(VCs) in UINavigationController with edge swiping.
I set up as following VC hierarchy:
UINagivationController
|
--- UIVewControllerR (root)
|
--- UIViewControllerA
|
--- UIViewControllerB
I tried to pop UIViewControllerB up by edge swiping and popped UIViewControllerA up continuously. It worked well. But, If first swiping action is canceled then retry to pop it up, a bug I found comes out. After popping UIViewControllerA, I found that UIViewControllerA's navigation bar items were still showed despite popping UIViewControllerA up.
In short, UIViewControllerR was showed with items of UIViewControllerA's navigation bar items.
There is no code that is likely to affect transition of UINavigationController.
Is it a bug on iOS7?
回答1:
I found a solution to this problem.
What I did was in my UINagivationController class, set a BOOL property called
@property (nonatomic, assign) BOOL interactivePopGestureComplete;
and then in init of that UINagivationController
self.interactivePopGestureComplete = YES;
if([self respondsToSelector:@selector(interactivePopGestureRecognizer)])
[self.interactivePopGestureRecognizer addTarget:self action:@selector(defaultGestureAction:)];
and the action method like this:
- (void)defaultGestureAction:(UIGestureRecognizer *)sender
{
if(sender.state == UIGestureRecognizerStateBegan || sender.state == UIGestureRecognizerStateChanged)
self.interactivePopGestureComplete = NO;
else
self.interactivePopGestureComplete = YES;
}
and in viewWillAppear: or viewWillLayoutSubviews: (in the viewControllers where there is this problem), wherever in these two methods you are updating the navigationBarButtons and the navigationBar, just check if
// Lets say our UINagivationController class name is NavigationCon
NavigationCon *navCon = (NavigationCon *)self.navigationController;
if(navCon.interactivePopGestureComplete)
{
// only then update navigationBar
}
回答2:
I can understand the problem your facing
There are two scenario's it can happen.
1.Where have you done Navigation Bar text changes in all controller.If you have done in viewWillAppear or viewDidAppear then this might happen..You will have to do it in viewDidLoad
2.Doing changes on the navigationbar before the transition changes end.
Tell me if it helps you.
来源:https://stackoverflow.com/questions/21298051/in-ios7-abnormal-popping-action-of-uinavigationcontroller-with-edge-swiping