我正在尝试在我的应用程序中显示模式弹出窗口。我确实看到它显示但框架不正确且方向箭头不可见
以下是我用来点击栏按钮时显示弹出窗口的代码
@IBAction func filterBarButtonAction(_ sender: AnyObject) {
let vc = UIStoryboard(name: "MapViewController", bundle: Bundle(for: type(of: self))).instantiateViewController(withIdentifier: "FilterModal")
vc.modalPresentationStyle = .overCurrentContext
vc.popoverPresentationController?.sourceRect = sender.bounds
vc.popoverPresentationController?.sourceView = sender as? UIView
vc.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.up;
vc.popoverPresentationController?.delegate = self
self.searchResultsController.present(vc, animated: true, completion: nil)
}
[当前视图显示如下] [1]
点击UIBarButton时,我需要做些什么更改才能显示带有箭头指示的弹出窗口
修改:根据Pierce的建议,当我改为
vc.modalPresentationStyle = .popover
答案 0 :(得分:0)
在我添加
后,它正在工作 public func adaptivePresentationStyle(for controller:UIPresentationController) -> UIModalPresentationStyle {
print("adaptive was called")
return .none
}
感谢Pierce,将modalPresentationStyle设置为popup是正确的方法