der*_*ida 13 quicklook ipad ios uidocumentinteraction swift
我已经为这个问题找到了一些解决方案(这是因为仍然有一个活动的动画引起的).
但是在iPad应用程序上使用UIDocumentInteractionController时,我无法在我的应用程序中解决这个问题.
我的ViewController看起来像
MainViewController - > ContainerView
在这个ContainerView我有一个侧边栏,从这个SideBar我想打开一个UIDocumentInteractionController.
我使用NSNotification,因为这个"MainViewController"应该处理来自不同视图的多个文件.
所以:(这是在我的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
}
Run Code Online (Sandbox Code Playgroud)
但生病总是得到以下错误:
警告:对QLRemotePreviewContentController的开始/结束外观转换的不平衡调用
我不知道为什么?应该没有动画,如果我打开另一个(模态)窗口,这里没有警告.
如果我使用延迟(例如5秒!),则会出现此警告.
编辑:发现我可能是我的ContainerView的问题.当我包含"ViewWillDissapear"和"ViewDidDisappear"时,我在这里得到错误:
view will dissappear
Unbalanced calls to begin/end appearance transitions for <QLRemotePreviewContentController: 0x7d35d400>
viww Did dissapaer
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?提前致谢
Ily*_*dov 18
您的应用程序必须使用导航控制器.如果是这种情况,导航控制器必须是处理预览交互的导航控制器,而不是其中的视图控制器.
更换你return self
的内部documentInteractionControllerViewControllerForPreview
与self.navigationController
应解决的问题.但是,您需要安全地打开包装navigationController
.请参阅以下完整方法:
func documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController) -> UIViewController {
if let navigationController = self.navigationController {
return navigationController
} else {
return self
}
}
Run Code Online (Sandbox Code Playgroud)
感谢@staxim的Objective-C解决方案!
归档时间: |
|
查看次数: |
6585 次 |
最近记录: |