I assume that you have added a navigation controller through Editor > Embed In > Navigation Controller in the xib (or formally nib) file in your XCode Projects’ Storyboard
Problem:
For example, you have added an Action button for Tweet Sheet on the Left, a Menu button on the right, and a Title button in the middle. But these three items don’t allow you to add a button at the second left position. This additional functionality enriches your app’s usp (unique selling point) or usability.
Reason:
It turns out this is a limitation of Interface Builder. It will only let you configure a single left and correct bar button item in a navigation bar. Don’t worry; you can still configure your remaining items in code. For example,
Solution:
Add the following code in the ‘viewDidLoad’ function in your View Controller’s Header file, i.e .h file
UIBarButtonItem *email = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(someAction)];
self.navigationItem.leftBarButtonItems = [self.navigationItem.leftBarButtonItems arrayByAddingObject:email];
So now your viewDidLoad function will look like this:
- (void)viewDidLoad
{
[super viewDidLoad];
//Add a compose button alongside the existing left bar button item from the storyboard.
UIBarButtonItem *email = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(someAction)];
self.navigationItem.leftBarButtonItems = [self.navigationItem.leftBarButtonItems arrayByAddingObject:email];
}
Now you can write a method for your added button like this:
- (IBAction)someAction
{
// Your code here...
}
Further Reading:
How to add four or more UIBarButtonitem at navigation bar with custom image through code?
Hope it helps,
Thanks & Regards
Mandar Apte
Thanks very much, I have three items on my navigation bar, two buttons on the left and right side of it and an image in the center. I followed your guide but it added the fourth button on the right side of the left button. I wanted to ask if you can help me on get it to the left side of the left button. And if you can also help me on setting a texture for this fourth button.
Thanks very much for your help.