title: How to use pencil (e.g. ink) annotation and finger touch navigation in PDFKit concurrently on iOS (Swift)?
body: <p>I wrote a PDF annotation App in Swift with PDFKit that uses touchesBegan/Moved/Ended to make annotations on a PDF. Works perfect for drawing annotations.</p>
  
  <p>In order to get the pencil touch events I needed to make a toggle button to set "isUserInteractionEnabled = false" on the PDFView if I do annotations and set "isUserInteractionEnabled = true" to navigate (pan/zoom) the PDF document.
  With "isUserInteraction = true" all the touch event are "eaten" by the PDFView (I think it's the documentView Scrollview) and are never called on the ViewController.</p>
  
  <p>The pepetual switching is really annoying for the user and not usable.</p>
  
  <p>So how do I use the touchesBegan/Moved/Ended overrides in the ViewController and being able to navigate (pan/zoom) in the PDF with finger touches without toggling isUserInteractionEnabled all the time?</p>
  
  <p>The App should run on iPad with pencil only.</p>
  
  <p>Thanks for taking your time,
  Lars</p>
  
  <p>Sample implementation to make things clearer:
  (inside class ViewController: UIViewController)</p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
  
      pdfView = PDFView()
  
      pdfView.translatesAutoresizingMaskIntoConstraints = false
      view.addSubview(pdfView)
  
      pdfView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
      pdfView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
      pdfView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
      pdfView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
  
      let url = Bundle.main.url(forResource: "TestPDF", withExtension: "pdf")!
      pdfView.document = PDFDocument(url: url)
  
      pdfView.isUserInteractionEnabled = false //touches events are called ... annotation with pencil mode
      //pdfView.isUserInteractionEnabled = true //touches events are NEVER called ... but pan/zoom works
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
      print("touchesBegan called!")
  
      if let touch = touches.first {
          if touch.type == .stylus {
              print("touchesBegan pencil annotation ...")
          }
      }
  }
  
  override func touchesMoved(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
      print("touchesMoved called!")
  
      if let touch = touches.first {
          if touch.type == .stylus {
              print("touchesMoved pencil annotation ...")
          }
      }
  }
  
  override func touchesEnded(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
      print("touchesEnded called!")
  
      if let touch = touches.first {
          if touch.type == .stylus {
              print("touchesEnded pencil annotation ...")
          }
      }
  }
  </code></pre>