簡體   English   中英

如何防止用戶點擊Popover之外的其他UIView(UIBarButtonItem)?

[英]How do I prevent the user from tapping other UIViews (UIBarButtonItem) outside a Popover?

在我的應用程序中,我有一個Popover,它是從UIToolbar中的UIBarButtonItem生成的。 當前,當顯示Popover時,可以點擊UIToolbar中的其他按鈕。

當在Popover外部點擊時,如何仍然關閉該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)
}

檢查passthroughViewsmodalInPopover屬性。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM