O iOS 11 PDFKit não atualiza a posição da anotação
Estou criando um aplicativo para editar PDFs no iPad.
Estou tentando implementar o arrastamento das anotações com um reconhecedor panGesture que eu adicionei à superview do PDFView. O problema é que os novos limites retos da anotação são atribuídos, mas as alterações não refletem na tela.
Aqui está o meu código:
@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
}
}
Espero que possa me ajudar.