如何转换此代码以使按钮显示在工具栏中? :
navigationItem.rightBarButtonItem = editButtonItem()
答案 0 :(得分:0)
试试这个,
let barButtonItem = UIBarButtonItem(title: "Edit", style: .Plain, target: self, action: "onEditButtonTapped:")
self.navigationItem.rightBarButtonItem = barButtonItem
然后编写动作函数,就像这样,
func onEditButtonTapped(sender:UIBarButtonItem) {
...
}
答案 1 :(得分:0)
试试这个:
self.navigationItem.setRightBarButtonItem(UIBarButtonItem(barButtonSystemItem: UIBarButtonItemStyle.Plain, target: self, action: "btnClicked:"), animated: true)
//adding function to bar button
func btnClicked(sender: UIBarButtonItem)
{
//your code here
}