UIDocumentInteractionController不使用多页的大型pdf文件。
在我的代码里,
var docController:UIDocumentInteractionController!..。
DispatchQueue.main.async (execute: { [weak self] in
self?.docController = UIDocumentInteractionController(url: pdfFileURL!)
self?.docController.delegate = self
self?.docController.name = pdfFileURL?.lastPathComponent
self?.docController.presentPreview(animated: true)
})以及委托方法,
func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
return self
}这是控制台的警告,
2017-05-26 12:46:51.178894 MyApp 3350:1136818视图服务终止时出现错误: Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)“UserInfo={Message=Service Message=Service中断} #Remote
下面是空白图片,

请帮帮我谢谢。
发布于 2017-05-26 10:44:47
就像这样:
声明:var interaction: UIDocumentInteractionController?
然后添加
interaction = UIDocumentInteractionController(url: URL(string: "<PDF FILE PATH>")!)
interaction.delegate = self
interaction.presentPreview(animated: true) // IF SHOW DIRECT或者如果需要的话会弹出任何建议。
interaction.presentOpenInMenu(from: /*<SOURCE BUTTON FRAME>*/, in: self.view, animated: true)实现代理-> UIDocumentInteractionControllerDelegate
public func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
return self
}
public func documentInteractionControllerDidEndPreview(_ controller: UIDocumentInteractionController) {
interaction = nil
}发布于 2019-02-28 11:33:17
检查文件扩展名或url路径是否包含".pdf“,以确保您的文件实际上是pdf文件。
否则,它将识别它为文本文件,而不会打开它。
发布于 2019-02-28 11:42:19
我上周刚刚实现了UIDocumentInteractionController,它运行得很好。
做一件事,声明为UIDocumentInteractionController作为var下面的类
然后像我一样在viewDidLoad()中进行分配和初始化
documentInteractionController = UIDocumentInteractionController.init()
documentInteractionController?.delegate = self当我呈现的时候,我把它做成这样
documentInteractionController?.url = url
documentInteractionController?.presentPreview(animated: true)希望它能解决你的问题。
https://stackoverflow.com/questions/44196066
复制相似问题