On iPhone OS 3.0, you can set UINavigationController toolbar items using the setToolbarItems:animated: method. However, this requires passing an array of UIToolbarItems elements. Although I could programmatically create these toolbar elements, I would rather create them in Interface Builder, if possible.
With this in mind, I created the UIToolbar in "MyGreatViewController.xib" and populated it with the necessary toolbar elements. Then in "MyGreatViewController.m" I get the elements from the toolbar and pass them to setToolbarItems:animated: ::
- (void)viewDidLoad { [super viewDidLoad]; [self setToolbarItems: [toolbar items]]; }
... where toolbar is an IBOutlet related to UIToolbar.
Is this a good approach? Is there a better way to do this? Should I just create items programmatically?
cocoa-touch interface-builder uinavigationcontroller uitoolbar uitoolbaritem
Steve harrison
source share