我已经将UIViewController定制为PopoverViewController,当我呈现它时,我无法触摸导航栏上的Tab栏
我一直在搜索,我得到了: 第一个ViewController代码的准备(对于segue:UIStoryboardSegue,sender:Any?):
if segue.identifier == "ShowChoice"{
let poper = segue.destination
poper.modalPresentationStyle = .popover
poper.popoverPresentationController?.delegate = self
let point = CGPoint(x: self.view.bounds.midX, y: self.view.bounds.midY + 5)
poper.popoverPresentationController?.sourceView = self.view
poper.popoverPresentationController?.sourceRect = CGRect(origin: point, size: CGSize.zero)
poper.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
//here I set [self.view] to passthroughViews and it work i can interact with all thing in self.view but I can't interact with Navigation Button or Tab bar item!
poper.popoverPresentationController?.passthroughViews = [self.view]
}
}
我只能将UIView设置为passthroughViews,但我想设置导航栏或标签栏
谢谢你!答案 0 :(得分:0)
我终于通过简单地将[self.tabBarController?.tabBar,self.navigationController?.navigationBar]转换为[UIView]
来自行找到poper.popoverPresentationController?.passthroughViews = [self.tabBarController?.tabBar,self.navigationController?.navigationBar] as! [UIView]
答案 1 :(得分:0)
有趣的是,popoverPresentationController.passthroughViews
中项目的顺序很重要!
例如,如果您想添加所有视图和导航栏,则必须将导航栏置于列表的开头,否则触摸只会被馈送到其下的任何项目
这是我的代码:
popoverPresentationController.passthroughViews = [self.view]
if let navBar = self.navigationController?.navigationBar {
popoverPresentationController.passthroughViews?.insert(navBar, at: 0)
}
此外,请记住关闭popoverView,因为这样做是为了能够使用后退按钮