About messages from UITapGestureRecognizer

前端 未结 3 512
清酒与你
清酒与你 2021-01-18 01:06

The following is from documentation :

Although taps are discrete gestures, they are discrete for each state of the gesture recognizer; thus the as

相关标签:
3条回答
  • 2021-01-18 01:34

    The UITapGestureRecognizer only fires when the gesture state is UIGestureRecognizerStateEnded

    If you want to use a gesture recogniser to detect the start and end of a press, use the UILongPressGestureRecognizer, with the minumumPressDuration set to 0

    0 讨论(0)
  • 2021-01-18 01:42

    Why don't you use - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event method ?

    0 讨论(0)
  • 2021-01-18 01:49
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    
          NSDate *date1 = [NSDate date]; //user touches the screen
    
    
    }
    
    -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
    
          NSDate *date2 = [NSDate date];  //user lifts his finger away from the screen
    
    }
    
    0 讨论(0)
提交回复
热议问题