Single Tap Not Getting Called in PDF View (in PDFKit)

Adding a single tap gesture to a PDFView doesn't work correctly. Code is not executed when tapping on the document in the PDFView:


In viewDidLoad() ->

//single tap gesture

let singleTap = UITapGestureRecognizer(target: self, action: #selector(singleTapped))

singleTap.numberOfTapsRequired = 1

pdfView.addGestureRecognizer(singleTap)


func singleTapped() {

//code to be executed_

}


Note though that if one taps on the light gray border around the document in the PDF view, the single tap code is executed. It‘s just that the single tap code isn’t executed when tapping on the document in the PDF view. This is still the case in iPadOS 13 beta 4. Note that the single tap gesture and the same code worked perfectly in iOS 12 when tapping on the document in the PDF view.


This clearly appears to be a bug and I have filed a feedback/bug report with Apple.

Replies

PDFKit adds a lot of new features in iOS 13. However, I prefers the original version of PDFKit before iOS 13!!! The new features block our custom UI a lot!!! 😟 Could anyone tell me how to use the original version of PDFKit in iOS 13?

Same problem here. After upgrading to iOS 13.1, the tap gesture recognizer does not work.

Same problem here.

Same problem here. After upgrading to iOS 13.1.2, the tap gesture recognizer does not work

Ipados 13.2 beta is working 👍

Can you please tell me what works exactly? I'm having this same issue. Are you saying the iOS Beta 2 gives us the ability to turn off the double tap to zoom feature? My assumption is the new double tap gesture swallows the single tap (that no longer works). Is this working with Xcode Beta 13.2?

Actually i installed the 13.2 Beta with the same issue, however i found a workaround for me. When i did add a tap gesture recognizer it was working on ios 13 however it would swallow up the taps on Links. Here's what i did to fix the issue:

I overrode the addGestureRecognizer on the subclass of PDFView, i then spin through and find the one that is a tap gesture 1 touch (this is provided by apple to handle the links clicking) and create my new tapgesture that i want to show/hide a menu (or your custom actions). I add it to the PDFView and require the built in one by apple to Fail (line 15).


I then allow the shouldRecognizeSimultaneouslyWithGesture which lets both tap gestures to call correclty. if you tap a link, my new one doesn't get called, but if you don't tap a link then it works perfectly and shows/hides my menu. I hope this is useful to someone!


- (void)addGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
{  
    if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]])
    {
        UITapGestureRecognizer *tapGest = (UITapGestureRecognizer*)gestureRecognizer;
        if (tapGest.numberOfTapsRequired == 1)
        {
            if (![tapGest isEqual:singleTapGesture])
            {
                if (![self.gestureRecognizers containsObject:singleTapGesture])
                {
                    singleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTap:)];
                    [singleTapGesture setNumberOfTapsRequired:1];
                    [singleTapGesture setDelegate:self];
                    [singleTapGesture requireGestureRecognizerToFail:tapGest];
                    [self addGestureRecognizer:singleTapGesture];
                }
            }
        }
    }
   
    [super addGestureRecognizer:gestureRecognizer];
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
  return YES;
}

Ditto...same problem. Same problem on IOS 13, 13.12, and 13.2 beta while all is fine on ios < 13 i.e. ios 12.4. PDF's made oin Adobe or any other source. Placing the same url in a button action works fine but the url as a pdf document link is inactive with a tap.