1

In my custom navigation bar, i want to use hide default back button and use my customize left button, but even if the back button is hidden, it sill take some space at the left end of navigation bar.

enter image description here

How to get rid of back arrow button completely? I have tried to set backBarButtonItem and 'hidesBackButtonproperties ofUINavigationItem`, but none of these works.

UPDATED:

- (void) viewDidLoad{
//...
self.navigationItem.hidesBackButton = YES;
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_backButtonView];
//...
}

I use Spark Inspector to inspect the view hierarchy.

enter image description here

As you see, the back arrow button still takes some space in navigation bar.

UPDATED:

The back arrow is actually an instance of _UINavigationBarBackIndicatorView, it look like a private class.

enter image description here

UPDATED:

It turns out the problem have nothing to do with the UINavigationbarBackIndicatorView. iOS 7 will add spacing before the left item.

this problem is similar to this. Found the answer.

Community
  • 1
  • 1
jAckOdE
  • 2,402
  • 8
  • 37
  • 67

2 Answers2

0

You should set hidesBackButton to YES before you push the controller. That is the navigation controller should be set hidebackbutton in previous viewcontroller if the pushing view must have hidden back button.

I hope this may help you.

RAJA
  • 1,214
  • 10
  • 13
  • I tried, it doesnt work. And it happen even with my first view controller in navigation stack. – jAckOdE Jan 20 '14 at 02:00
  • I meant i have a leftbutton item for root view controller, but in the navigation bar, the hidden back arrow still take space the and make the leftbutton item shift a bit the the right. – jAckOdE Jan 20 '14 at 02:49
  • In root view controller its not possible for back button in navigation controller. Its not hideBackButton problem I think. If you are using the navigation bar image then can you please check whether that image contains the back arrow. If not then its some other problem for it. check for the logic you have done before u load the navigation root viewcontroller – RAJA Jan 20 '14 at 02:56
  • check my update, i did set bg for navigation bar image, but the arrow is instance of UINavigationBarBackIndicatorView. And if the back arrow is part of the bg image, it will NOT take space like that. – jAckOdE Jan 20 '14 at 03:03
0

It turns out my problem is similar to this

The solution from that question work for me.

Community
  • 1
  • 1
jAckOdE
  • 2,402
  • 8
  • 37
  • 67