swift - PDFKit 无法在 iOS 13 和 iPhone 11、XR 等上绘制图像注释
问题描述
我被分配了一个任务,我应该在这些图像之间绘制一些图像和一些直线。我用这个方法成功地做到了,
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 上运行良好。任何可能的解决方案?
解决方案
我遇到了类似的问题,点击手势没有添加到PDFView上。这可能是因为视图堆叠,我不确定。但我通过在我的PDFView顶部添加另一个UIView并在其上添加轻击手势来解决它。
推荐阅读
- node.js - 使用 mongoose 和 NodeJS 在 Mongo DB 中嵌套查询
- javascript - React Native,无效的 Prop 源
- python - 检查文件是否仍然在python中打开
- c++ - 在 Linux 或 Windows 上生成 c++ 项目的 windows 可执行文件
- ruby-on-rails - 如何保留 PORO 表单对象字段输入?
- mysql - MYSQL:如何获取按日期分组的唯一值?
- javascript - JSON.stringify 将不同的值返回到简单的控制台日志
- javascript - 如何告诉 Vuejs 查看子数据条目
- c++ - 没有转换函数 c++
- r - 有没有办法根据在 R 中用逗号分隔值的列对数据进行分组?