1

I am currently developing a chat application and within this I have to add more then 1 left bar button in navigation bar. I am developing it using xib file.

I already added left and right bar button now I want to add 2 more in the left side of navigation bar.

halfer
  • 19,824
  • 17
  • 99
  • 186
Rahul
  • 49
  • 1
  • 7
  • 1
    You'l get many, if you just google ***uinavigationbar multiple buttons*** – Kumar KL Sep 04 '14 at 10:53
  • possible duplicate of [How to add 2 buttons into the UINavigationbar on the right side without IB?](http://stackoverflow.com/questions/1803609/how-to-add-2-buttons-into-the-uinavigationbar-on-the-right-side-without-ib) – Kumar KL Sep 04 '14 at 10:54
  • @rahul you have to give some reply about answer and comment. – Nitin Gohel Sep 05 '14 at 12:16

1 Answers1

8

UINavigationItem Class Reference having property of leftBarButtonItems and rightBarButtonItems so you can add multiple UIBarButtonItem in your navigation control using following example code:

 UIBarButtonItem *FirstButton = [[UIBarButtonItem alloc] 
                               initWithTitle:@"First"                                            
                               style:UIBarButtonItemStyleBordered 
                               target:self 
                               action:@selector(AcionFirst:)];

   UIBarButtonItem *secondButton = [[UIBarButtonItem alloc] 
                               initWithTitle:@"Second"                                            
                               style:UIBarButtonItemStyleBordered 
                               target:self 
                               action:@selector(AcionSecond:)];


   self.navigationItem.leftBarButtonItems= [NSArray arrayWithObjects:FirstButton,secondButton,nil];


-(void)AcionFirst:(id)sender
{  
    //do something for first bar button

}

-(void)AcionSecond:(id)sender
{
    //do something for second bar button
}
Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144