添加的UIBarButtonItem不执行任何操作

时间:2017-02-22 18:56:00

标签: uibarbuttonitem

我想更改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)

}

0 个答案:

没有答案