使用 pdfkit 显示 pdf
using pdfkit to display pdf
我正在尝试加载存储在我的应用程序中的 pdf
,这是我拥有的代码
import UIKit
import PDFKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let pdfView = PDFView(frame: UIScreen.main.bounds)
let url = Bundle.main.url(forResource: "example", withExtension: "pdf")
pdfView.document = PDFDocument(url: url!)
self.view.addSubview(pdfView)
}
When I am running in simulator, I am getting the error that fatal error: unexpectedly found nil while unwrapping an Optional value in the debug are it is showing that url is nil .Any idea how to resolve it? I am running swift 4 and iOS 11 as target
请单击文件检查器中目标成员资格下的复选框。
我正在尝试加载存储在我的应用程序中的 pdf
,这是我拥有的代码
import UIKit
import PDFKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let pdfView = PDFView(frame: UIScreen.main.bounds)
let url = Bundle.main.url(forResource: "example", withExtension: "pdf")
pdfView.document = PDFDocument(url: url!)
self.view.addSubview(pdfView)
}
When I am running in simulator, I am getting the error that fatal error: unexpectedly found nil while unwrapping an Optional value in the debug are it is showing that url is nil .Any idea how to resolve it? I am running swift 4 and iOS 11 as target
请单击文件检查器中目标成员资格下的复选框。