简体   繁体   中英

How do I add a UIBarButtonItem to a navigation bar?

Prior to iOS 8 I could simply drag the UIBarButtonItem from the object library to a navigation bar. But now I simply can't if it is not the first view controller on the navigation stack.

I know I can do it in code but is there any way I can make it happen in Storyboard?

Yes you can. First drag-drop a UINavigationItem to your ViewController. This will add a title bar. Then drag a UIBarButtonItem and drop in the nav bar. This works.

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