Navigation stack becomes unusable after canceling iOS 7 back

I ran into a problem when my navigation controller becomes unusable after starting, and then cancels the new gesture of the iOS 7 hard drive.

Some relevant information:

  • My application has a homepage with various activity pages.
  • Home page hides navigation bar in WillAppear view
  • Home page does not hide navigation bar in WillDisappear view

    -(void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; // Let hide the navbar when we show the home view [self.navigationController setNavigationBarHidden:YES]; … } -(void) viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; // Let hide the navbar when we show the home view [self.navigationController setNavigationBarHidden:NO]; } 

When the user clicks the activity icon on the home page, the view controller for activity is pushed onto the stack.

If the user starts using the new hard drive gesture in iOS, but then stops the gesture (i.e. decides not to return), everything looks fine. However, if the user forces another view controller to be pushed onto the navigator stack, then the nag bar becomes unusable and the user cannot switch back from the current view controller.

Notes

  • This happens when I show / hide the navigation bar.
  • I can still execute the gesture back, and everything will work fine until I cancel the gesture.
  • The navigation bar seems to work, but clicking on the back button does not appear in the view controller.
+25
ios ios7 uinavigationcontroller uinavigationbar
Nov 11 '13 at 20:50
source share
4 answers

Not sure if you already solved this, but I ran into the same problem, but with one difference. The navigation stack only gets confused if I set it to No.

So this works:

 [self.navigationController setNavigationBarHidden:YES animated:YES]; ... [self.navigationController setNavigationBarHidden:NO animated:YES]; 

but this is not so:

 [self.navigationController setNavigationBarHidden:YES animated:NO]; ... [self.navigationController setNavigationBarHidden:NO animated:NO]; 

If you really want the animated one to be NO for any reason, one job is to set the alpha value to 0/1 instead of hiding / opening the navigation bar:

 - (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 disadvantage is that there is no nice animation of the transition to the slide. If you find a better way, let us know.

UPDATE This is already old, but I solved my problem by not guaranteeing that any state in the current viewWillDisappear would be restored to viewWillAppear. Do not pluck things in the view. See what you cannot configure again.

This is what happens when you cancel the pop animation:




  • Current ViewWillDisappear
  • New viewWillAppear
  • [canceled ... cancels]
  • New viewWillDisappear
  • New viewDidDisappear
  • Current ViewWillAppear
  • Current viewDidAppear



I think that in this bold new world, viewWillDisappear / viewWillAppear does not always mean that "will disappear / appear" :)

+16
Feb 08 '14 at 22:40
source share

I think my decision can help you.

Suppose the controller class of your home version is HomePageViewController (class name), and the activity type controller is called ActivityViewController (also the class name)

First, in the HomePageViewControllerWillAppear view:

 - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:YES]; } 

Secondly, in your ActivityViewController add the following codes:

 - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:NO animated:YES]; } - (void)viewWillDisappear:(BOOL)animated { //trick to fix navigationbar disappear problem that when UIScreenEdgePanGesture is happening. if ([self.navigationController.topViewController isKindOfClass:[HomePageViewController class]]) { [self.navigationController setNavigationBarHidden:YES animated:YES]; } else { [self.navigationController setNavigationBarHidden:NO animated:YES]; } [super viewWillDisappear:animated]; } 
+3
Apr 17 '14 at 4:59
source share

I had the same problem, and after searching, it looks like you cannot get a notification if the gesture is canceled. There is no -shouldCancel gesture recognizer -shouldCancel , and no -shouldCancel on the navigation controller. Therefore, I have a view controller that needs a displayed navigation bar (i.e. a controller that is canceled) sets self.navigationController.navigationBarHidden = NO to -viewWillAppear . Thus, when the gesture is canceled and -viewWillAppear is -viewWillAppear , the navigation bar will be hidden again. As far as I can tell, this is the only way so that when deleting gestures there are no swipe gestures nor shown / hidden navigation panels.

+1
Dec 23 '13 at 3:26
source share

I managed to solve this problem using animated: true in viewWillAppear and animated: false in viewWillDisappear second view controller

0
Feb 22 '17 at 21:30
source share



All Articles