Popover在iOS 8中工作,但在iOS 7中不工作

Popover在iOS 8中工作,但在iOS 7中不工作,ios,swift,uipopovercontroller,Ios,Swift,Uipopovercontroller,在iOS 7中运行我的应用程序时,我在尝试显示popover时出现以下错误: [UIPopoverController解除锁定]在popover仍然可见时到达 它在iOS 8中运行良好 显示弹出窗口的代码是: let vc = InfoViewController() vc.setText(txt) vc.modalPresentationStyle = .Popover var w=vc.width if w<200 { w=200 } vc.preferredContentSiz

在iOS 7中运行我的应用程序时,我在尝试显示popover时出现以下错误: [UIPopoverController解除锁定]在popover仍然可见时到达

它在iOS 8中运行良好

显示弹出窗口的代码是:

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)
let vc=InfoViewController()
vc.setText(txt)
vc.modalPresentationStyle=.Popover
var w=vc.width

如果要解决这个问题,一个简单的方法是将popover声明为类的成员变量并使用它

var aPopover : UIPopoverController?
在该方法中,更改代码如下:

self.aPopover =  UIPopoverController(contentViewController: vc)
self.aPopover!.presentPopoverFromRect(popRect, inView: view, permittedArrowDirections: UIPopoverArrowDirection.Any, animated: true)

真是太棒了!现在我遇到了一个问题,dismissViewController似乎不适用于iOS 7中的弹出窗口。对这个问题有什么想法吗?@FloydResler:你能解释一下这个问题吗?您是如何实现dismissViewController的?