我正在构建一个应用程序来编辑iPad上的PDF。iOS 11 PDFKit不更新注释位置
我正试图用我添加到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
}
}
希望你能帮助我。