I have a UINavigationController
. I\'m trying to add multiple buttons on the right side of my navigationBar. How can I achieve this?
What kind of button does it take
there's actually even a bit ore hacky, but at the same time more cleaner way of doing this stuff: just define a category on UINavigationItem, like:
UINavigationItem+Toolbars.h:
@interface UINavigationItem (Toolbars)
@property (nonatomic, retain) IBOutlet UIToolbar * rightToolBar;
@property (nonatomic, retain) IBOutlet UIToolbar * leftToolBar;
- (void)setRightToolBar:(UIToolbar *)_rightToolBar;
- (UIToolbar *)rightToolBar;
- (void)setLeftToolBar:(UIToolbar *)_leftToolBar;
- (UIToolbar *)leftToolBar;
@end
UINavigationItem+Toolbars.m:
#import "UINavigationItem+Toolbars.h"
@implementation UINavigationItem (Toolbars)
- (void)setRightToolBar:(UIToolbar *)_rightToolBar {
self.rightBarButtonItems = _rightToolBar.items;
}
- (UIToolbar *)rightToolBar {
return nil;
}
- (void)setLeftToolBar:(UIToolbar *)_leftToolBar {
self.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:_leftToolBar] autorelease];
}
- (UIToolbar *)leftToolBar {
return nil;
}
@end
After doing that, just assign an outlet in IB settings a toolbar (just create one) and enjoy buttons appearing on the navigation item.