let obj = MainStoryboard().instantiateViewController(withIdentifier: "SomeVC") as! SomeVC
obj.delegate = self
obj.modalPresentationStyle = .popover
obj.popoverPresentationController?.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
self.present(obj, animated: true, completion: nil)
在设置断点时,调试器一直运行到最后一行。之后,它直接进入AppDelegate
班级第一行。
我已经正确设置了异常断点。我可能在哪里犯错?它与sourceView
for相关popoverPresentationController
吗?我不知道。
我想做的是设置popoverPresentationController
中心。有什么帮助吗?
编辑:
我添加sourceView
到代码中,如下所示,现在它正在工作:
obj.popoverPresentationController?.sourceView = self.view
obj.popoverPresentationController?.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 1, height: 1)
但是,它不在屏幕中央。放截图供参考。如何使其到达中心并移除方向箭头?