Adding two right bar button items to the navigation bar

12,163

Solution 1

This code will do the trick for you,

 NSArray *barButtonItems= [[NSArray alloc] initWithObjects:self.addButton,self.sortbyButton,nil];
self.navigationItem.rightBarButtonItems=barButtonItems;

where addButton and sortbyButton are 2 separate BarButton Items

Solution 2

I know it is too late but I faced it recently. So here is what I did Create a UIView in code and add the buttons as subviews into this view. Create a ToolbarButton using [[UIBarButtonItem alloc] initWithCustomView:buttons]

Assign this toolbar button as the Left or right barbuttonItem as U wish.

Share:
12,163
Raj
Author by

Raj

Updated on June 19, 2022

Comments

  • Raj
    Raj almost 2 years

    I have a navigation bar to which I have added right BarButton successfully. Both the NavigationBar and BarButton are created programmatically. Now according to my requirement I got to add two right BarButtons to my navigation Bar. Can anyone tell me how to do this? My app is targeting ios4.