IPhone - UINavigationItem - hides a button

I'm at a dead end. I am using the UINavigationController, and on one view, I am trying to hide the back button. But when I do this, it hides the back button on the next level of views.

In - (void)viewWillAppear:(BOOL)animatedI have:

[self.navigationItem setHidesBackButton:YES animated:NO];

And in - (void)viewWillDisappear:(BOOL)animatedI have:

[self.navigationItem setHidesBackButton:NO animated:NO];

It just makes the back button appear before it exits (which seems to be the correct functionality of this call). So I'm tired of setting

[self.navigationItem setHidesBackButton:NO animated:NO];

in the - (void)viewWillAppear:(BOOL)animatednext view, and it still doesn't work.

This is a bit confusing as it self.navigationItem.backBarButtonItemis a reference to what this button will display back when this view is under the top view (ref). But it self.navigationItem.hidesBackbuttonshows if the back button is displayed when it is a top view ( ref ). So can anyone understand why he is hiding the back button of the next view?

Another weird thing - it works when I look down. For a more visual presentation, let's say I have the following views:

A > B > C > D

B - , . "" , A. , "" C. D, "" , , ". , C, B. B. , C, "", .

?

+3
3

, - "" UINavigationController. backButton of NavigationController .

, , , .

  • setHidesBackButton:animated: viewDidAppear:, viewWillAppear:
  • self.navigationItem.hidesBackButton .
+9

, setHidesBackButton, viewDidLoad :

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[[UIView alloc] init]];
+4

I think you know that hiding the back button does not prevent the user from clicking on it?

To prevent a click, you must set it to zero.

 self.navigationItem.leftBarButtomItem = nil;

Then you can create a new back button in method "B" viewWillAppear.

+1
source

Source: https://habr.com/ru/post/1779008/


All Articles