Swift iOS-触发SplitViewController的displayModeButtonItem时的触发操作

时间:2017-05-27 14:58:59

标签: ios swift uisplitviewcontroller uisplitviewdelegate

我有一个SplitViewController,我正在实施:

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

当iPhone 6 Plus或7 Plus处于.regular方向时,我用它来显示视图控制器上的展开按钮。我想在触摸按钮时触发动作。我是怎么做到的?

enter image description here

1 个答案:

答案 0 :(得分:0)

只需在按钮上设置action即可。

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

此外,您还需要设置目标,即接收动作的对象。在你的情况下可能是self

myNavVC?.topViewController?.navigationItem.leftBarButtonItem.target = self