【发布时间】:2018-03-25 19:34:47
【问题描述】:
我正在构建一个在 iPad 上编辑 PDF 的应用程序。
我正在尝试使用我添加到 PDFView 的超级视图的 panGesture 识别器来实现注释的拖动。问题是注释的新矩形边界已分配,但更改并未反映在屏幕上。
这是我的代码:
@objc func handlePanGesture(panGesture: UIPanGestureRecognizer) {
let touchLocation = panGesture.location(in: pdfView)
guard let page = pdfView.page(for: touchLocation, nearest: true) else {
return
}
let locationOnPage = pdfView.convert(touchLocation, to: page)
switch panGesture.state {
case .began:
guard let annotation = page.annotation(at: locationOnPage) else {
return
}
currentlySelectedAnnotation = annotation
case .changed:
guard let annotation = currentlySelectedAnnotation else {
return
}
let initialBounds = annotation.bounds
annotation.bounds = CGRect(origin: locationOnPage,
size: initialBounds.size)
print("move to \(locationOnPage)")
case .ended, .cancelled, .failed:
break
default:
break
}
}
希望你能帮助我。
【问题讨论】: