ToolBar in Navigation Based Application
Since my last post I'm moving ahead. My Navigation Based Application has to contain toolbar at t开发者_StackOverflow社区he bottom of UIViewController. I googled a couple of hours and found a lot of regarding stuff.... well at least I've found this page:
http://frog.io/blog/ios-toolbars
Implemented and got my toolbar buckled up. There's only problem that no single bar button item is visible. So, I need two advices:
- How to make em visible?
- Is this approach correct enough? I mean wouldn't it be rejected by Apple?
Adding a UIToolbar to a UINavigationController based application is actually deceptively easy. Per the UINavigationController Class Reference, there is a built-in UIToolbar, which is hidden by default.
To show the toolbar try this in your UIViewController subclass:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[[self navigationController] setToolbarHidden:NO animated:YES];
}
To add items to the toolbar, you simply use the - (void)setToolbarItems:(NSArray *)toolbarItems animated:(BOOL)animated
during - (void)viewDidLoad
or similar.
You will need to remember to hide the toolbar during - (void)viewDidDisappear:(BOOL)animated
unless you want it to hang around as other UIViewControllers are pushed and popped.
精彩评论