[英]Popover works in iOS 8 but not iOS 7
When running my app in iOS 7 I get the following error when trying to display a popover: [UIPopoverController dealloc] reached while popover is still visible 在iOS 7中运行我的应用程序时,尝试显示弹出窗口时出现以下错误:[UIPopoverController dealloc]仍然显示弹出窗口
It works fine in iOS 8. 它在iOS 8中工作正常。
My code to show the popup is: 我显示弹出窗口的代码是:
let vc = InfoViewController()
vc.setText(txt)
vc.modalPresentationStyle = .Popover
var w=vc.width
if w<200 {
w=200
}
vc.preferredContentSize = CGSizeMake(w+30,height+30)
let popRect = rect
let aPopover = UIPopoverController(contentViewController: vc)
aPopover.presentPopoverFromRect(popRect, inView: view, permittedArrowDirections: UIPopoverArrowDirection.Any, animated: true)
An easy way to fix this is declare your popover as a member variable of your class and using it. 解决此问题的一种简单方法是将弹出窗口声明为类的成员变量并使用它。
var aPopover : UIPopoverController?
And in that method change the code like: 然后在该方法中更改代码,例如:
self.aPopover = UIPopoverController(contentViewController: vc)
self.aPopover!.presentPopoverFromRect(popRect, inView: view, permittedArrowDirections: UIPopoverArrowDirection.Any, animated: true)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.