开发者

How can I add a UIToolbar to a UIViewController?

I have a UIViewController. I want to add a UIToolbar to the bottom, but IB is not letting me. How can I achieve this?

Note: The UIViewC开发者_如何学编程ontroller is part of a UINavigationController. I'm not sure if this affects the visibility of the toolbar.


Starting from iOS 3.0 you can set toolbar items you want using following UIViewController's method:

- (void)setToolbarItems:(NSArray *)toolbarItems animated:(BOOL)animated

of simply set or override toolbarItems property.

And toolbar will appear automatically if you put your view controller inside navigation controller.


You can't add toolbar in IB, in IB all you can do is - set a dummy toolbar / navigation bar / tabBar etc. so that you can simulate them to arrange your view's subviews appropriately.

To set the toolbar for that viewController, you have to fill the UIViewController's:

setToolbarItems:animated:

or

@property(nonatomic, retain) NSArray *toolbarItems

so this toolbar and its items will be displayed when your viewController is presented.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜