我正在構建一個應用程序來編輯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
}
}
希望你能幫助我。