0 Replies
      Latest reply on Feb 13, 2020 8:46 AM by rick@peekemon
      rick@peekemon Level 1 Level 1 (0 points)

        I am unable to get a UIViewController to receive the UIPencilInteractionDelegate “pencilInteractionDidTap” method in response to double taps from an Apple Pencil. I am testing on iPad Pro 11 and 12.9 models, both running iOS 13.3.1

         

        I have implemented the following:

         

        extension UIViewController: UIPencilInteractionDelegate {

            public func pencilInteractionDidTap(_ interaction: UIPencilInteraction) {

                print("Handle pencil double-tap")

            }

        }

         

        In my UIViewController:

         

        override func viewDidAppear(_ animated: Bool) {

                super.viewDidAppear(animated)

              

          let pencilInteraction = UIPencilInteraction()

                pencilInteraction.delegate = self

                view.addInteraction(pencilInteraction)

        }

         

         

        Note: If I create a new Single View iOS app and add this code, everything works as expected.

         

        However the above code does not work with the custom UIViewController in my app. My UIViewController’s view hosts a UIScrollView as well as overlaying Container Views and handles touch events in both the View Controller and ScrollView classes.

         

        I have also tried adding the UIPencilInteraction object to other UIViewControllers in my app and the “pencilInteractionDidTap” method  is not called in any of them.

         

        Do I need to change something in the Responder chain to get the UIViewController to handle “pencilInteractionDidTap” method calls?