Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

lawicko

macrumors member
Original poster
Jul 17, 2008
44
0
Ok, so here is what I want to do - I want to customize my navigation bar so that I have more than 2 buttons on it. I saw the NavBar example, but this is not what I want. I have no problem in putting UIButton or UISegmentedControl or anything else that is derived from UIView on the navigation bar. However, I don't know how to put UIBarButtonItem as additional button :confused:

This really made me confused, because the only way I know to add buttons is to use titleView of my view controller. And this is really easy, you just have to add something that is derived from UIView as a subview of titleView. To my surprise, UIBarButtonItem is not derived from UIView, so it cannot be added as a subview, preventing a container designed to be used on tab bar to be placed on the boody tab bar.

I hope someone here can help me with it :eek:
 

beachdog

macrumors member
Aug 10, 2008
86
0
I did something like this once; unfortunately I later decided to change the code and I didn't save a code snippet showing how I did it. However, I *think* what I did is have a custom view for the right bar button, and I had that custom view be a segmented control. In that segmented control I then added my two UIBarButtonItems.

BTW, in my case it was suggested to me that a better UI approach than adding these two actions to the navbar was to create a toolbar down below for actions, and keep the navbar simply to navigation and basic edit operations. That is why I eventually decided against going this route.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
The reason they aren't views is because they're model objects. You are interacting with the navigation controller and its model objects, not the views and its subviews.

If you need to add a view as a button, use initWithCustomView: and set your button as the view.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.