iOS 8多个弹出窗口 - “警告:尝试在*上显示*已经呈现(null)”

时间:2015-12-11 13:10:55

标签: ios iphone uipopovercontroller uipopover

我有两个UIBarButtonItem,它们都在我的iOS 8应用程序中打开了带有导航控制器的popover。两者都使用storyboards设置,类型为Present As Popover,“动画”设置为true。 “锚点”设置为对应的UIBarButtonItem

在代码中,这是在呈现popover /执行segue之前的配置。

override public func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
   if segue.identifier == SEGUE_ID_ADD_ACTION {
        if let actionViewController = (segue.destinationViewController as! UINavigationController).topViewController as? ActionViewController {
            let newAction = Action()
            actionViewController.selectedAction = newAction
            actionViewController.delegate = self
        }
    }
    else if segue.identifier == SEGUE_ID_FILTER {
        let controller = (segue.destinationViewController as! UINavigationController).topViewController as! FilterViewController
        controller.delegate = self
        controller.setup(filter)
        segue.destinationViewController.popoverPresentationController!.delegate = controller
    }
}

两个显示的视图控制器类都没有更多的popover特定代码:

let size = CGSizeMake(320, 460)
self.navigationController?.preferredContentSize = size
viewWillAppear

中的

我遇到的问题是当出现弹出窗口A时我按下按钮打开弹出窗口B.日志中显示错误,没有任何反应。优选地,弹出B应该显示或者隐藏弹出B(类似于弹出弹出框之外的任何其他位置)。日志错误:

 Warning: Attempt to present <UINavigationController: 0x7fbdac027000>  on <xxx.ActionListViewController: 0x7fbdac075000> which is already presenting (null)

1 个答案:

答案 0 :(得分:2)

添加

self.navigationController?.popoverPresentationController?.passthroughViews = nil

在popover中的包含viewcontroller中至少固定,因此在单击navigationitem中的另一个按钮时会触发另一个popover的解除。