Link to the back button on the UINavigationBar

I need a link to the back button in a UINavigationBar or UINavigationItem . Back button in the image below.

Navigation bar

I do not configure the button this way

 navigationItem.backBarButtonItem navigationItem.leftBarButtonItem 

these values ​​are zero.

Is there a way to get a link to a button without setting it up?

Link:

Update. My comment can help understand why I don’t want to customize the back button. :)

+5
source share
4 answers

The Documentation talks about this backBarButtonItem:

When this element is the inverse element of the navigation bar - when it is the next element below the top element - it can be represented as a back button on the navigation bar. Use this property to specify the back button. The default value is a button that displays the title of the navigation items.

Thus, backBarButtonItem always nil by default, because it belongs to the previous view controller. The only way to get a non-zero link is to set it up.

If you just want to change the name, however, this can be done in the previous view controller.

+4
source

Regarding my use case - Ayush comment

As long as I get a specific solution, I created a dummy view under the navigation bar (below the back button) to display a hint. Here is the code.

 let v = UIView(frame: CGRectMake(0, 0, 50, 0)) view.addSubview(v) let tipText = "Here it the back button" EasyTipView.showAnimated(true, forView: v, withinSuperview: view, text:tipText, preferences: nil, delegate: self) 
+1
source

try this one

 let backItem = UIBarButtonItem(title: "Custom Text HERE", style: .Bordered, target: nil, action: nil) navigationItem.backBarButtonItem = backItem 
+1
source

Try it, it can help you.

  UINavigationItem *i = [self.navigationController.navigationBar.items firstObject]; i.title = @"Hai"; 
+1
source

All Articles