开发者

ToolBar in Navigation Based Application

开发者 https://www.devze.com 2023-04-10 04:27 出处:网络
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 r

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:

  1. How to make em visible?
  2. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号