In iPhone OS 3.0, you can set the toolbar items of a UINavigationController using the setToolbarItems:animated:
method. However, this requires you pass in an array of UIToolbarItems. While I could programmatically create these toolbar items, I'd rather create them in Interface Builder if possible.
With this in mind, I have created a UIToolbar in "MyGreatViewController.xib" and have populated it with the wanted toolbar items. Then, in "MyGreatViewController.m", I get the items from the toolbar and pass them to setToolbarItems:animated:
:
- (void)viewDidLoad {
[super viewDidLoad];
[self setToolbarItems: [toolbar items]];
}
...where toolbar
is an IBOutlet referring to the UIToolbar.
Is this a good approach? Is there a better way to accomplish this? Should I just create the items programmatically?