如何阻止用户在Popover外部点击其他UIViews(UIBarButtonItem)?

时间:2018-03-19 16:14:15

标签: ios swift uikit

在我的应用程序中,我有一个从UIToolbar中的UIBarButtonItem生成的Popover。目前,当显示Popover时,可以点击UIToolbar中的其他按钮。

如果在外面点击Popover,同时也不允许用户点击Popover外面的UIViews,我怎么仍然将其解雇?我只需要禁用Popover外部的视图吗?

// prepare Actions Menu
let storyboard = UIStoryboard(name: "Main", bundle: nil)

actionsVC = storyboard.instantiateViewController(withIdentifier: "actionsViewController") as! ActionsController
actionsVC.modalPresentationStyle = .popover
actionsVC.graph = graph
actionsVC.viewControllerDelegate = self

...

@IBAction func openActionsPopover(_ sender: UIBarButtonItem) {
        actionsVC.popoverPresentationController?.barButtonItem = sender
        actionsVC.popoverPresentationController?.passthroughViews?.removeAll()
        present(actionsVC, animated: true)
}

1 个答案:

答案 0 :(得分:0)

检查passthroughViewsmodalInPopover属性。