无法在 iOS Swift 中单击 UIBarButtonItem 添加目标和 运行 功能 3

Unable to add target and run function on UIBarButtonItem click in iOS Swift 3

我无法在 Swift 3 中检测到 UIBarButtonItems 上的点击事件。任何人都可以帮忙吗?我需要对另一个故事板执行 segue 并在单击 UIBarButtonItem 时执行 view controller

检查下面的示例代码:-

var b = UIBarButtonItem(
    title: "Continue",
    style: .plain,
    target: self,
    action: #selector(sayHello(sender:))
)

func sayHello(sender: UIBarButtonItem) {
}

Swift 3.0:

 override func viewDidLoad() {
   super.viewDidLoad()
   let controllerButton: UIBarButtonItem = UIBarButtonItem.init(title: "Next", style: .plain, target: self, action: #selector(ViewController.changeController))
self.navigationItem.rightBarButtonItem = controllerButton
  }

func changeController() {
self.performSegue(withIdentifier: "Controller name segue", sender: AnyObject) 
}

请检查上面的代码以创建 UIBarButtonItem 并将其与目标和操作一起保留在正确的导航项上。