6

I am trying to add two right buttons to the navigation bar. I tried adding using following ways but I get SIGABRT

  1. self.navigationController.navigationBar.items = navItemsArray;
  2. self.navigationItem.rightBarButtonItems = navItemsArray;

navItemsArray has two buttons of type UIBarButtonItem.

Can anyone help with this? I can't figure out what is wrong.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
pa12
  • 1,493
  • 4
  • 19
  • 40
  • 1
    This stackoverflow thread gives some good answers: http://stackoverflow.com/questions/1803609/how-to-add-2-buttons-into-the-uinavigationbar-on-the-right-side-without-ib – TheEye Nov 08 '11 at 15:32

3 Answers3

16
self.navigationItem.rightBarButtonItems = navItemsArray;

works only in iOS 5.

Josh Brown
  • 52,385
  • 10
  • 54
  • 80
pa12
  • 1,493
  • 4
  • 19
  • 40
0

do you have callbacks for the buttons? Did you "wire up" the buttons by option-clicking them and dragging them to something?

You need to have the buttons connected to an IBAction.

nycynik
  • 7,371
  • 8
  • 62
  • 87
  • http://www.ios-developer.net/iphone-ipad-programmer/development/window-uiviewcontroller-etc/navigation-bar/adding-navigation-bar-buttons – nycynik Nov 08 '11 at 15:11
0

You cannot add directly two UIBarButtonItem in UINavigationBar. But use UIToolBar to have same effect as of Navigation Bar. You can add any controls in UIToolBar Such as switch, segmentedControl etc.

For more help on Code please refer the previous post Link1 and Link2

Community
  • 1
  • 1
DShah
  • 9,768
  • 11
  • 71
  • 127