1 Reply
      Latest reply on Dec 2, 2015 4:35 AM by Appersian
      Appersian Level 1 Level 1 (0 points)

        I am trying to run a method by 2 times tapping on tv remote, consider tapping not clicking, but the touch surface does't recognize the taps. Instead, clicking two times runs the doubleTapping method.

         

        UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
            doubleTap.allowedTouchTypes =@[[NSNumber numberWithInteger:UITouchTypeIndirect]];
            doubleTap.numberOfTapsRequired = 2;
            [self.view addGestureRecognizer:doubleTap];
        - (void)handleTap:(UITapGestureRecognizer *)sender
        {
            if (sender.state == UIGestureRecognizerStateBegan)
            {
                /
                NSLog(@"2 times");
            }
        }
        

         

        I am missing something ?

        • Re: Having issue with number of taps in UITapGestureRecognizer
          Appersian Level 1 Level 1 (0 points)

          was forgot to mention the UIPressType value , now due to position of remote's surface (Up / Down / Right / Left) you can now detect user's tap direction and add numberOfTapsRequired to the action :

           

          UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; [tapGestureRecognizer setAllowedPressTypes:@[@(UIPressTypeLeftArrow)]]; [tapGestureRecognizer setNumberOfTapsRequired:2]; [self.view addGestureRecognizer:tapGestureRecognizer];