答案 0 :(得分:1)
如果你想以编程方式创建它,你可以在你的视图中尝试加载方法
let rightBarButton = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.plain, target: self, action: #selector(ViewController.myRightSideBarButtonItemTapped(_:)))
self.navigationItem.rightBarButtonItem = rightBarButton
let leftBarButton = UIBarButtonItem(title: "Edit", style: UIBarButtonItemStyle.done, target: self, action: #selector(ViewController.myLeftSideBarButtonItemTapped(_:)))
self.navigationItem.leftBarButtonItem = leftBarButton
//Mark - Call functions
func myRightSideBarButtonItemTapped(_ sender:UIBarButtonItem!)
{
print("myRightSideBarButtonItemTapped")
}
func myLeftSideBarButtonItemTapped(_ sender:UIBarButtonItem!)
{
print("myLeftSideBarButtonItemTapped")
}