So as my question states, I'm trying to add custom buttons to a UINavigationBar
. AFAIK, you can only add a leftbutton
and a rightbutton
. However, I want to add 2 more, 1 on each side of the title. Is there any way to do this? :)
Asked
Active
Viewed 301 times
0

Kirit Modi
- 23,155
- 15
- 89
- 112

Lorenzo Ang
- 1,202
- 3
- 12
- 35
-
Just checked it out. Thanks! :) – Lorenzo Ang Jan 28 '15 at 07:28
2 Answers
0
You can easily add more buttons to both sides by accessing the following:
- create programatically the buttons that you want.
- get a reference to the navigationitem buttons array
add the buttons to the array like this:
rightAddButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(doSomething:)]; editButtonItem = ....; self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:self.editButtonItem,rightAddButton,nil];

Kirit Modi
- 23,155
- 15
- 89
- 112

EmilDo
- 1,177
- 3
- 16
- 33
-1
Other than what you mentioned, UINavigationItem
has two more properties called leftBarButtonItems
and rightBarButtonItems
. You can use those properties to add multiple items.
Always suggest developers to loop up the documentation.

Lucas Huang
- 3,998
- 3
- 20
- 29
-
Hey Lucas! Thanks for your answer! I've been doing that but I didn't realize you could add more than one to them. Check Anbu's comment! :) – Lorenzo Ang Jan 28 '15 at 07:34