ios - 警告 : Unbalanced calls to begin/end appearance transitions for QLRemotePreviewContentController

标签 ios ipad swift uidocumentinteraction quicklook

我已经找到了这个问题的一些解决方案(这是因为仍然有一个事件的动画引起的)。

但是当我在 iPad 应用程序上使用 UIDocumentInteractionController 时,我无法在我的应用程序中解决这个问题。

我的 ViewController 看起来像

主视图 Controller -> 容器 View

在这个 ContainerView 中我有一个边栏,我想从这个边栏打开一个 UIDocumentInteractionController。

我使用 NSNotification,因为这个“MainViewController”应该处理来自不同 View 的多个文件。

所以:(这是在我的 MainViewController 中)

func openFile(notification: NSNotification){

    fileUrl = notification.object as NSURL

    var documentInteractionController = UIDocumentInteractionController(URL: self.fileUrl!)
    documentInteractionController.delegate = self

    documentInteractionController.presentPreviewAnimated(false)
}

func documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController) -> UIViewController {
    return self
}

但我总是会得到以下错误:

警告:对 QLRemotePreviewContentController 的开始/结束外观转换的调用不平衡

不知道为什么?应该没有动画,如果我打开另一个(模式)窗口,这里没有警告。

如果我使用延迟(例如 5 秒!),仍然会出现此警告。

编辑:发现我的 ContainerView 可能有问题。当我包含“ViewWillDissapear”和“ViewDidDisappear”时,我会在此处收到错误消息:

view will dissappear

Unbalanced calls to begin/end appearance transitions for <QLRemotePreviewContentController: 0x7d35d400>

viww Did dissapaer

有什么想法吗?提前致谢

最佳答案

您的应用程序必须使用导航 Controller 。如果是这种情况,导航 Controller 必须是处理预览交互的 Controller ,而不是其中的 View Controller 。

documentInteractionControllerViewControllerForPreview 中的 return self 替换为 self.navigationController 应该可以解决问题。但是,您需要安全地解包 navigationController。请参阅下面的完整方法:

func documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController) -> UIViewController {
    if let navigationController = self.navigationController {
        return navigationController
    } else {
        return self
    }
}

感谢 @staxim 的 Objective-C 解决方案!

关于ios - 警告 : Unbalanced calls to begin/end appearance transitions for QLRemotePreviewContentController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26309793/

相关文章:

swift - Firebase Twitter oAuth 回调不适用于 Swift ios13

ios - 在 iOS 的屏幕上和屏幕外动画 View

ios - 显示游戏中心排行榜无法快速工作

ios - 在实体异常中找不到 keypath objectID

ios - UIPopoverController 中的 UIImagePickerController 显示为空白 View

swift - 快速执行功能映射的时间

android - 将iOS coredata导入android sqlite

iphone - CLLocationManager 地理围栏/startMonitoringForRegion : vs. startMonitoringForSignificantLocationChanges : vs. 10 分钟开始更新调用

javascript - 如何拦截长按UIWebView中的链接?

objective-c - 将 objective-c 转换为 swift : @() syntax