У меня есть WKWebView, который отображает PDF.Я хочу поделиться файлом с другими устройствами, такими как iPad, iPhone .... с помощью кнопки поделиться.Я попытался отобразить PDF в предварительном просмотре, чтобы на нем была кнопка «Поделиться с iOS» с кодом ниже.
import UIKit
import WebKit
class ShowPDFView: UIViewController, UIDocumentInteractionControllerDelegate {
@IBAction func SharePDFFile(_ sender: Any) {
let fileName = "testPDF"
guard let urlPath = Bundle.main.url(forResource: fileName, withExtension: "pdf") else {return}
let controller = UIDocumentInteractionController(url: urlPath)
controller.delegate = self
controller.presentPreview(animated: true)
}
func documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController!) -> UIViewController! {
return self
}
func documentInteractionControllerViewForPreview(controller: UIDocumentInteractionController!) -> UIView! {
return self.view
}
func documentInteractionControllerRectForPreview(controller: UIDocumentInteractionController!) -> CGRect{
return self.view.frame
}
Я получил ошибку во время выполнения.
[MC] Reading from private effective user settings.
Предварительный просмотр не загружен.Кто-нибудь знает почему?