How to remove the back arrow ios 7 navigation bar?

自作多情 提交于 2020-01-05 14:02:32

问题


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.

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.

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.

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.


回答1:


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.




回答2:


It turns out my problem is similar to this

The solution from that question work for me.



来源:https://stackoverflow.com/questions/21224974/how-to-remove-the-back-arrow-ios-7-navigation-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!