I have a splitViewController and I would like to add a couple of buttons to the navigation bar for certain details views - is this possible? Looking at the API I only see a leftNavbarItem and a rightNavBarItem.
+2
A:
If you create a UIToolBar
, add your buttons to it, and then make it your leftNavBarItem
or rightNavBarItem
, the navigation bar is smart enough to make the buttons appear as though they're sitting on the navigation bar. So you get the illusion of having multiple button items when they are in fact part of a toolbar.
Also, I'd advise against using UIButton
and use UIBarButtonItem
instead. Bar button items are designed to look "right" when sitting on a navigation bar or toolbar. I'd steer clear of UIButton
unless you need a custom look, and even then it needs to be embedded in a UIBarButtonItem
as a custom view.
Alex
2010-07-25 18:42:37
Huh, I never knew that! Thanks! Don't your buttons get pretty crowded?
Steve
2010-07-26 13:37:35
In an iPad app, there's usually room for two or three icon buttons on a side, or two text buttons. Any more than that and it probably will get pretty crowded.
Alex
2010-07-30 22:13:38