【发布时间】:2018-07-12 15:01:19
【问题描述】:
import UIKit
import WebKit
class ViewController: UIViewController, UIDocumentInteractionControllerDelegate {
var docController: UIDocumentInteractionController!
override func viewDidLoad() {
super.viewDidLoad()
docController = UIDocumentInteractionController.init(url: URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(urlVal!))
docController.delegate = self
docController.presentPreview(animated: true)
}
func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
return self
}
}
以上代码我无法显示 pdf 文件。有人可以帮忙吗?
【问题讨论】:
-
您的 docController 是在哪里定义的?我在上面的代码中看不到。
-
嗨,我在顶部定义