0

I have a SplitViewController and I'm implementing:

myNavVC?.topViewController?.navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem
myNavVC?.topViewController?.navigationItem.leftItemsSupplementBackButton = true

I use it to display the expand button on the view controller when the iPhone 6 Plus or 7 Plus is in .regular orientation. I would like to trigger an action when the button is touched. How I do this?

enter image description here

4

1 回答 1

0

Simply set action on button.

myNavVC?.topViewController?.navigationItem.leftBarButtonItem.action = #selector(foo)

Also you need to set the target, the object with receive the action. Probably it would be self in your case.

myNavVC?.topViewController?.navigationItem.leftBarButtonItem.target = self
于 2017-05-27T15:08:18.963 回答