How to enable selection of continous text in PDFView so that I can add annotations?

911 Views Asked by At

Currently I have rendered an sample pdf file on PDFView using PDFDocument.

pdfView.autoScales = true
pdfView.displayDirection = .horizontal
pdfView.displayMode = .singlePage
pdfView.usePageViewController(true, withViewOptions: [UIPageViewControllerOptionInterPageSpacingKey: 20])
pdfView.document = pdfDocument

So when I swipe on the view it slides to next or previous page respectively as I'm using pageViewController.

The problem arises here,

If I want to annot certain part of text then as I start dragging on the text it slides to next page instead of continous selection of the text.

If I do long press, then im only able to select one word or the native OS selection with Copy, Selectall pop's up which is not my requirement.

As user starts selecting the text I need to add annotation of highlight.

1

There are 1 best solutions below

0
On

For any of those who are still stuck with the above problem, solution is just a one line

pdfView!.isUserInteractionEnabled = !pdfView.isUserInteractionEnabled

will disable the scroll of pdfview subview.

To enable the scroll back just use the same line mentioned above.