Objective c UITapgestureRecognitor中的点击数有问题 我尝试在电视遥控器上运行2次代码代码>,考虑攻丝不>强>点击,但触摸面不识别水龙头。相反,单击两次将运行doubleTapping方法 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) { // handling code NSLog(@"2 times"); } }

Objective c UITapgestureRecognitor中的点击数有问题 我尝试在电视遥控器上运行2次代码代码>,考虑攻丝不>强>点击,但触摸面不识别水龙头。相反,单击两次将运行doubleTapping方法 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) { // handling code NSLog(@"2 times"); } },objective-c,uitapgesturerecognizer,tvos,apple-tv,Objective C,Uitapgesturerecognizer,Tvos,Apple Tv,我遗漏了什么?我忘了提及UIPressType值,现在由于遥控器表面的位置(上/下/右/左),您现在可以检测用户的点击方向,并将所需的点击次数添加到动作中: UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; [tapGestureRecognizer setAllowedPres

我遗漏了什么?

我忘了提及
UIPressType
值,现在由于遥控器表面的位置(上/下/右/左),您现在可以检测用户的点击方向,并将
所需的点击次数添加到动作中:

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