我想更改UIBarButtonItem显示,我可以添加一个没有问题的按钮,但添加的UIBarButtonItem不会执行任何操作。有人请帮忙吗?
let leftBarButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.action, target: self, action: #selector(sayHello))
func sayHello() {
print("Hello")
}
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.setLeftBarButton(leftBarButton, animated: true)
}