我有一个使用 PDFKIT 创建的 PDF 视图,它在 iPad 中加载 PDF。当我们缩放 PDF 并进行一些手绘时,它会崩溃。可能是什么问题?
问问题
399 次
1 回答
0
我有一个类似的问题,放大具有多个子类型 .ink 的 PDFAnnotations 的文档会导致内存使用量迅速达到峰值并且我的应用程序崩溃。当时,我使用 PDF 页面边界启动了我的每个绘图注释,如下所示:
let inkAnnotation = PDFAnnotation(bounds: page.bounds(for: pdfView.displayBox), forType: .ink, withProperties: nil)
解决我的问题并摆脱我的性能问题的方法是使用代表页面上绘图的 UIBezierPath 的边界框来启动 PDFAnnotation,而不是使用整个 PDF 页面的边界来启动它。
let inkAnnotation = PDFAnnotation(bounds: bezierPath.bounds, forType: .ink, withProperties: nil)
只需确保相对于您的 PDF 页面正确转换贝塞尔路径边界即可。Artem Poluektov 的本指南可能是一个很好的起点。
于 2020-09-09T13:39:22.103 回答