Add a tap gesture recognizer to PDFView in iOS 13

My code works in iOS 12. But after upgrading to iOS 13, it does not work.

let pinPointRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.pinPoint(sender:)))
pinPointRecognizer.numberOfTapsRequired = 1

I have tried adding the pinPointRecognizer.numberOfTouchesRequired = 2 and it can trigger pinPoint() function. But I want to trigger pinPoint() in a single tap.

Is this behaviour a bug that will be fixed in the future iOS version? Is there a workaround to fix this?



Thank you all for your reply! I am sorry that I may not have the time to test all your answers. I have changed my app's behaviour to work around the problem.

I need to pin a point on PDF file. My workaround is to add an additional layer, which display a pin icon on the center of the PDFView. When a user tap on the PDF view, I will add one pin icon image annotation on the PDFView.

In a word, in my workaround, I still use the tap gesture recognizer. But the recognizer only pin a point on the center of current PDFView. User can zoom in/out and drag around to control where to pin the point.

let singleTapGesture = UITapGestureRecognizer(target: self, action: #selector(toggleTopBottomView(_:)))
singleTapGesture.numberOfTapsRequired = 1
singleTapGesture.delegate = self

@objc func toggleTopBottomView(_ sender: UITapGestureRecognizer){


func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
    return true

Single Tap Not Getting Called in PDF View (in , Code is not executed when tapping on the document in the PDFView: When i did add a tap gesture recognizer it was working on ios 13 however it would  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.

the bug seems to be solved on the iOS 13.2 version. Unfortunately I could not find a workaround to solve this issue.

iOS PDFKit Ink Annotations Tutorial - Better Programming, This tutorial was updated to iOS 13, you'll also find some useful information If it's multi-touch gesture, I set gesture recognizer state to .failed , so that Add this gesture recognizer to your PDFView by adding this code to your  UITap Gesture Recognizer is a concrete subclass of UIGesture Recognizer. For gesture recognition, the specified number of fingers must tap the view a specified number of times. Although taps are discrete gestures, they are discrete for each state of the gesture recognizer.

You can try this with Xcode 11, iOS 13

override func viewDidLoad() {

    let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))

    tap.numberOfTapsRequired = 1


    view.isUserInteractionEnabled = true


@objc func handleTap(_ sender: UITapGestureRecognizer) {

How to detect a double tap gesture, The iOS UITapGestureRecognizer class has a built-in way to detect a the recognizer, set its numberOfTapsRequired property to 2, then add it  Download the sample. The tap gesture is used for tap detection and is implemented with the TapGestureRecognizer class. To make a user interface element clickable with the tap gesture, create a TapGestureRecognizer instance, handle the Tapped event and add the new gesture recognizer to the GestureRecognizers collection on the user interface element. The following code example shows a TapGestureRecognizer attached to an Image element:

Actually i installed the 13.2 Beta with the same issue, however i found a workaround for me. I tested it with 13.1 and it works as well. 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;

UIGestureRecognizer Tutorial: Getting Started, Swift 5, iOS 13, Xcode 11 In iOS, gestures like taps, pinches, pans or rotations are used for user input. In your app, you can react to gestures, like a tap on button​, without ever thinking about how to detect them. But in In this tutorial, you'll learn how to add gesture recognizers to your app, both within the  Tap gesture recognizer in ios (Swift 4 and Xcode 9) IOS Image Picker using Swift3 (with Tap Gesture) Pan Gestures - Gesture Recognizers in IOS 12,

Drawing on PDFs Using Ink Annotations, For iOS users, Apple's PDFKit provides tools to implement this functionality. the initial boilerplate code ready, let's start with annotateButton 's tapped method: The `panGestureRecognizer` will take care of handling touches and drawing the to disable pdfView 's user interaction and add our pan gesture recognizer,  For instance, you can add both pinch and rotation gesture recognizers to an imageview, so you can zoom in/out and rotate the presented image. However, just one gesture at a given time can occur. Gesture recognizers that are related to a view are added to an array of that view, so you can access them as you would do for any object to a normal array.

Newest 'ios-pdfkit' Questions, Add a tap gesture recognizer to PDFView in iOS 13 · uitapgesturerecognizer ios13 ios-pdfkit · Jan 9 at 23:11 Matt Long. 0. 0  Lastest vs 2019 16.5.3 installed xam ios but can't test as provisioning profiles and certificates are not received from mac anymore and are not listed in VS dropdowns on windows. Did not have this problem with previous VS version.

User ysong4, 5 Add a tap gesture recognizer to PDFView in iOS 13 Sep 30 '19. 1 ARKit cannot rotate a SCNNode correctly on a vertical plane Oct 25 '19. 1 How do I set bold  Gesture Recognizers can be used to detect user interaction with many elements of a Xamarin.Forms Application. The Tap Gesture is used for tap detection and is implemented with the TapGestureRecognizer class.

  • This works for me, and doesn't conflict with taps on links.
  • can you convert that to a swift function?