swift - 注释而不是在 PDFView 中选择文本
问题描述
我正在编写一个允许创建注释的 PDF 查看器。我已经想出了如何创建跨越当前选定文本的(标记)注释:
let pdfView = PDFView()
let selectionsByLine = pdfView.currentSelection.selectionsByLine()
for line in selectionsByLine {
for page in line.pages {
let bounds = line.bounds(for: page)
let annotation = PDFAnnotation(bounds: bounds,
forType: .highlight,
withProperties: [:])
page.addAnnotation(annotation)
}
}
但我想允许用户通过选择它来选择一个工具和标记文本。到目前为止,我已经想到了两种方法:
- 我想知道我是否可以子类
PDFView
化并以某种方式捕获选择文本时触发的事件/手势。 - 我也想用
UIPanGestureRecognizer
它来识别“选择”,但我需要禁用默认选择,或者以某种方式重新设置它的样式。
我对 UIKit 不太熟悉,所以我希望有人能指出我正确的方向:D
解决方案
推荐阅读
- python - 如何在不知道部分名称的情况下根据键查找值
- java - 如何让 Timer ActionListener 在启动前等待另一个停止
- java - 在某些手机上存在连接错误
- python - 如何使用 kafka-python 以编程方式创建主题?
- r - R dplyr mutate 条件 when_case 无法更新数据帧
- php - 解析图像网址(来自服务器)并将其存储到内部存储中的有效方法?
- ios - 如何将评论从 UIViewController 发送到另一个 UIViewController 并将它们存储在数组中?
- php - 查找与类别无关的产品
- android - 从 Google Play 商店安装应用程序后仅显示卸载按钮
- javascript - socket.io 和异步事件