I would like to have two rightBarButtonItems on navigation bar. One for Edit and the other for Add.
Obviously I can\'t make it using Interface Builder.
Does anyb
You can do it from Interface Builder. What I have done in my app - just added UIView on left Item of navigation bar and placed 3 buttons in this view and connected their action. You can follow this to add more than one button in left/right navigation item.
Refered: Toolbar items in sub-nib
Heres an example of how you can add two buttons as the rightbarbutton. The code below creates a segmentedcontrol containing up and down arrow buttons, which is then added as a customview for navigation's rightbarbutton:
UISegmentedControl* segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray array]];
[segmentedControl setMomentary:YES];
[segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"icon-triangle-up.png"] atIndex:0 animated:NO];
[segmentedControl insertSegmentWithImage:[UIImage imageNamed:@"icon-triangle-down.png"] atIndex:1 animated:NO];
segmentedControl.autoresizingMask = UIViewAutoresizingFlexibleWidth;
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
[segmentedControl addTarget:self action:@selector(segmentedAction:) forControlEvents:UIControlEventValueChanged];
UIBarButtonItem * segmentBarItem = [[UIBarButtonItem alloc] initWithCustomView: segmentedControl];
self.navigationItem.rightBarButtonItem = segmentBarItem;
if someone is passing by, here is the swift answer :
let barButton_array: [UIBarButtonItem] = [Button1, Button2]
navigationItem.setRightBarButtonItems(barButton_array, animated: false)