[英]Display popover as full screen for iPhone
I am trying to use UIPopoverPresentationController
to display a popover that doesn't take up the whole screen. 我正在尝试使用UIPopoverPresentationController
来显示不会占据整个屏幕的弹出窗口。 already checked this and other tutorials, but don't worked. 已经检查过本教程和其他教程,但是没有用。
Here my code: 这是我的代码:
@IBAction func temp(_ sender: UIButton) {
let vc = UIStoryboard(name: "StayView", bundle: nil).instantiateViewController(withIdentifier: "StayViewPopOverViewController") as! StayViewPopOverViewController
vc.modalPresentationStyle = .popover
vc.preferredContentSize = CGSize(width: 180, height: 75)
let popover = vc.popoverPresentationController!
popover.sourceView = self.btnTemp
popover.sourceRect = self.btnTemp.bounds
popover.delegate = self
self.present(vc, animated: true, completion: nil)
}
My delegate method: 我的委托方法:
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController!) -> UIModalPresentationStyle {
return .none
}
but that cover Whole screen. 但覆盖整个屏幕。
I tried to put breakpoint on delegate method but interpreter didn't stop on that. 我试图在委托方法上设置断点,但解释器并没有就此停止。
can anyBody have any solution or any suggetions? anyBody可以提出任何解决方案或建议吗?
Update following lines 更新以下行
vc.modalPresentationStyle = .popover
vc.preferredContentSize = CGSize(width: 180, height: 75)
with 与
vc.modalPresentationStyle = .overFullScreen
vc.preferredContentSize = view.frame.size
Finally I Got the answer. 最后我得到了答案。
Just need to update my delegate method like this: 只需要像这样更新我的委托方法:
func adaptivePresentationStyle(
for controller: UIPresentationController,
traitCollection: UITraitCollection)
-> UIModalPresentationStyle {
return .none
}
Thats It... Works Great!!! 多数民众赞成在...工作很棒!!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.