2017-10-13 4 views
1

iPad에서 PDF를 편집하는 앱을 제작하고 있습니다.iOS 11 PDF 주석이 주석 위치를 업데이트하지 않습니다

필자는 PDFView의 수퍼 뷰에 추가 한 panGesture 인식기로 주석을 드래그하여 구현하려고합니다. 문제는 주석의 새로운 rect 경계가 할당되지만 변경 사항이 화면에 반영되지 않는다는 것입니다.

@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 
    } 
} 

당신이 나를 도울 수 있기를 바랍니다 :

여기 내 코드입니다.

답변

1

글쎄, 아무도 대답하지 못했습니다. 프레임 워크에 버그가 있다고 생각합니다. 그래서 시행 착오를 거쳐 저에게 도움이되는 것을 게시 할 것입니다.

let initialBounds = annotation.bounds 
annotation.bounds = CGRect(
     origin: locationOnPage, 
     size: initialBounds.size) 
page.removeAnnotation(annotation) 
page.addAnnotation(annotation) 

그것은 우아한 아니지만, 그것은 작업 Bezierpath에게 경계 변화에 전체 bezierpath 이동을 사용하여

0

않습니다.

PDF의 기본 라인 유형은 경계가 바뀌지 않고 이동하지 않으므로 변경 될 때마다 startPoint 및 endPoint를 설정해야합니다.