I see a bunch of apps for iPad with really cool title bars. These seem to be a combination of a navigation bar and a toolbar. They usually have a back button and a title as well as men other buttons. And a navbar only supports a left item, a right item and and title view. And the toolbar does not really support back buttons or titles.
So how do I implement these rich navbars with many buttons on my UINavigationController driven application?
Most of these applications are using a UISplitViewController at their base level, with a UIToolbar at the top of the larger right-hand detail view for the split view controller. The left-hand view is provided by a UINavigationController. This gives you the navigation controls in the toolbar on the left, as well as multiple toolbar buttons on the right. These are separate bars at the top of the screen, but they can appear to merge together if the same style is used for both.
For an example of how to do this, you can download the source code to my universal iPhone / iPad application Molecules and look inside the SLSMoleculeAppDelegate, where I construct the split view controller in code, and the SLSMoleculeiPadRootViewController, where I set up the toolbar and its items.
You can get this effect by putting a UIToolbar
in your UINavigationItem
like so:
self.navigationItem.title = @"My Title";
UIToolbar *tb = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
tb.items = [NSArray arrayWithObjects:button1,button2,button3,nil];
UIBarButtonItem *tbItem = [[UIBarButtonItem alloc] initWithCustomView:tb];
self.navigationItem.rightBarButtonItem = tbItem;
[tbItem release];
[tb release];
source: this blog, via google.
You can also hide navigation controller withself.navigationController.navigationBarHidden = YES;
.
But at same time, add a back button on the left of toolbar, which will call popviewcontrollers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With