PopViewController strange behaviour

前端 未结 5 983
忘掉有多难
忘掉有多难 2021-01-20 03:01

Due to a weird request which I tried to turn down but it didn\'t work, I had to override the navigationBar\'s back Button.

I have made a custom UINavigationControlle

5条回答
  •  萌比男神i
    2021-01-20 03:34

    You probably need to do [super shouldPop... instead of actual [self popViewControllerAnimated:YES];.

    The reason being that the way UINavigationController implements stack is private, so you should mess with the method calls as little as possible.

    Anyway, this looks like a hack. Moreover, the user will have no visual clue that you are blocking the navigation action. What's wrong with disabling the button via:

    self.navigationController.navigationItem.backBarButtonItem.enabled = NO; 
    

提交回复
热议问题