Avatar ·

适用于iOS的快速轻量PDF查看器:技巧与建议

大家好!我正在开发一个iOS应用,需要显示PDF文档(用户手册、目录)。问题是文件可能很大——达到100-200 MB,标准的UIScrollView和UIWebView会卡顿,有时甚至崩溃。我尝试过使用PDFKit,但发现在滚动包含大量矢量图形(图表、图纸)的页面时,会出现明显的延迟。 以下是我当前的代码: ```swift import PDFKit class PDFViewController: UIViewController { var pdfView: PDFView! var document: PDFDocument? override func viewDidLoad() { super.viewDidLoad() pdfView = PDFView(frame: view.bounds) pdfView.autoresizingMask = [.flexibleWidth, .flexibleHeight] view.addSubview(pdfView) if let url = Bundle.main.url(forResource: "manual", withExtension: "pdf") { document = PDFDocument(url: url) pdfView.document = document pdfView.autoSca