【问题标题】:Unable to draw Image Annotation on iOS 13 and iPhones 11, XR etc by PDFKitPDFKit 无法在 iOS 13 和 iPhone 11、XR 等上绘制图像注释
【发布时间】:2020-02-04 17:20:08
【问题描述】:

我被分配了一项任务,我应该在其中绘制一些图像和这些图像之间的一些直线。我用这个方法成功了,

    class PDFImageAnnotation: PDFAnnotation {

    var image: UIImage?

    convenience init(_ image: UIImage?, bounds: CGRect, properties: [AnyHashable : Any]?) {
        self.init(bounds: bounds, forType: PDFAnnotationSubtype.ink, withProperties: properties)
        self.image = image
    }

    override func draw(with box: PDFDisplayBox, in context: CGContext) {
        super.draw(with: box, in: context)

        // Drawing the image within the annotation's bounds.
        guard let cgImage = image?.cgImage else { return }
        context.draw(cgImage, in: bounds)
    }
}

现在,每当用户点击 PDF 页面时,我只需在该位置添加此图像注释。在 iOS 13 发布后,每当我点击 PDF 页面时,它都不会显示图像注释,尽管我收到了触摸代表并且我的代码在 iOS 12 上运行良好。任何可能的解决方案?

【问题讨论】:

    标签: swift pdf annotations ios13 ios-pdfkit


    【解决方案1】:

    我遇到了类似的问题,PDFView 上没有添加点击手势。这可能是因为视图堆叠,我不确定。但我通过在我的 PDFView 之上添加另一个 UIView 并在其上添加点击手势来解决它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-18
      • 2018-04-06
      • 2018-03-25
      • 1970-01-01
      • 1970-01-01
      • 2020-03-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多