如何将 UIBarButtonItem 添加到导航栏?

How do I add a UIBarButtonItem to a navigation bar?

在 iOS8 之前,我可以简单地将 UIBarButtonItem 从对象库拖动到导航栏。但是现在,如果它不是导航堆栈上的第一个视图控制器,我根本做不到。

我知道我可以在代码中做到这一点,但有什么方法可以在 Storyboard 中实现它吗?

是的,你可以。首先 drag-drop 一个 UINavigationItem 到你的 ViewController。这将添加一个标题栏。然后将 UIBarButtonItem 拖放到导航栏中。这行得通。