Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add multiple buttons to a NavigationBar? [duplicate]

Ok, so I've successfully added a rightBarButtonItem to call a custom selector (called from a UIViewController), as follows:

 UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];

 [infoButton addTarget:self action:@selector(showInfoView:) forControlEvents:UIControlEventTouchUpInside];

 self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:infoButton];

Is it possible to make the "right bar button item" actually be several distinct buttons (and thus remove the title text from the navigation bar)?

I'm searching for ways to get more screen real estate, and this seems like a logical choice... although any other suggestions would be appreciated (maybe i should reduce the size of the tab bar i use at the bottom...)

like image 249
Matt Avatar asked Mar 09 '10 22:03

Matt


1 Answers

UIBarButtonItem *addAcc = [[UIBarButtonItem alloc] 
                               initWithTitle:@"Add"                                            
                               style:UIBarButtonItemStylePlain 
                               target:self 
                               action:@selector(addNewAcc)];

UIBarButtonItem *delAcc = [[UIBarButtonItem alloc] 
          initWithTitle:@"Del"                                            
          style:UIBarButtonItemStylePlain 
          target:self 
          action:@selector(DeleteButtonAction)];

NSArray *arrBtns = [[NSArray alloc]initWithObjects:addAcc,delAcc, nil];
self.navigationItem.rightBarButtonItems = arrBtns;
like image 81
iPhone Programmatically Avatar answered Sep 19 '22 19:09

iPhone Programmatically