Question: Tried this but only works for UIButton:

```
[btn setTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];

```

Answer: 
Set `target` and `action` of your `UIBarButtonItem`

**Swift 5 & 4**

```
button.target = self
button.action = #selector(action)

@objc func action (sender:UIButton) {
    print("action")
}

```
For custom views: use an `UITapGestureRecognizer` and set up `isUserInteractionEnabled` to `true`.

```
profileImageView.isUserInteractionEnabled = true
let tap = UITapGestureRecognizer(target: self, action: #selector(handleProfileImageTap))
profileImageView.addGestureRecognizer(tap)
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: profileImageView)

```