我有一个问题,想要在导航栏中添加右侧按钮。
我有两个视图:视图 A 和视图 B。
我给视图 A 添加了导航栏,在使用 self.navigationController!.pushViewController
显示视图 B 后,导航栏的左侧自动显示了返回按钮,这很好。但是现在我想在导航栏的右侧添加一个按钮。我尝试了一些答案,但是它们都不起作用... 我尝试了以下答案:
1) https://www.hackingwithswift.com/example-code/uikit/how-to-add-a-bar-button-to-a-navigation-bar 2) http://blog.apoorvmote.com/add-multiple-bar-button-item-navigation-bar/?lang=fr
你能帮我吗?谢谢!
let rightBtn = UIBarButtonItem(title: "Send", style: .Plain, target: self, action: "send:") self.navigationItem.setRightBarButtonItem(rightBtn, animated: true)
的答案。我知道我可以使用XIB来实现这个功能,但是我不知道为什么右侧按钮的位置与我的XIB不同,所以我使用代码来实现它。 - user2262304