When I push a new view controller onto the navigation stack, the leftbarbuttonitem changes into the Title of the previous view controller, as expected. But I need to add an additional button to the nav bar, just to the right of the back button. I still want the back button to work as normal. Any suggestions on how to do this?
views:
73answers:
1
+2
A:
You need to add a custom view on the navigationbar. Then, implement 2 buttons and add them on the custom view, one for back button, and one for additional button you want.
The navigationBar can be obtained by the property of UINavigationController.
Edit:
UINavigationBar class Reference, it is a sub-class of UIView.
Toro
2010-08-31 01:46:12
How can you set/add a custom view on navigation bar. There is no API that I can see to do that. Or you mean to add a subview inside navigationBar?
vodkhang
2010-08-31 02:06:21
navigationBar is a sub-class of UIView, so you can add a subview inside navigationBar.
Toro
2010-08-31 03:12:29
I have basically done this, but the problem is that you can't programatically create a "Back" button. You can choose either backBarButtonItem or leftBarButtonItem. If you choose leftBarButtonItem you can't place the back button inside it.
sol
2010-09-02 17:58:14
Yes. it is because you use UIBarButtonItem for button on UINavigationBar. And what I said is to use 2 UIButtons and UIView which are put above UINavigationBar.
Toro
2010-09-02 23:02:18