简体   繁体   中英

iOS PdfKit select and delete note annotation when long pressed/tapped

I am adding annotations to a pdf document and this works as expected. Now I also want to delete them and here I am facing some issues. As I see, it should work out of the box, but when I long click on an annotation mostly of the time the text around of it is being selected but not the annotation itself.

This is one example where I created a big annotation so that I am sure that my finger is not touching any text around of it. When I long click on it this is what I get most of the time (this is not always, sometimes the menu also appears over the annotation and I am able to delete it via the delete action):

在此处输入图像描述

I also tried to add a long-press/tap gesture on the PDFKit and in these situations when I long click on the annotation and the text is being selected, my long press gesture is not being fired. I assume that the view hierarchy inside PDFKit is causing this issue.

With the tap gesture I am able to detect the annotation when it's being tapped, but in this case the controller?? that is displaying the annotation text is not being shown (I guess because I intercept the tap gesture). Is there a way to still trigger the annotation display and modify the controller (add additional navigation button since now there is just a "Done" button)? This is the particular controller when I tap the orange note icon:

Adding hightlight annotations to text and removing them works as expected (because there is no problem with selecting text)

Is there a way to somehow force the PDFKit to mark the annotation as selected when I long click on it? Modifying the controller that is being displayed when an annotation is being tapped would also help.

在此处输入图像描述

In case somebody else is struggling with this. I chose to display the annotation inside a custom controller. First I implemented a TapGestureRecognizer on the pdfview, from there got the annotation and then displayed the annotation inside the custom controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM