简体   繁体   中英

Adding buttons to navigation bar ios

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.

self.navigationItem.rightBarButtonItems = navItemsArray;

仅适用于iOS 5。

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM