How can the action for a custom UIBarButtonItem in Swift be set?
The following code successfully places the button in the navigation bar:
var b = UIB
Swift 4/5 example
button.target = self button.action = #selector(buttonClicked(sender:)) @objc func buttonClicked(sender: UIBarButtonItem) { }