当用户触摸视图时,我只想检测双击/单击。
我做了这样的事情:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint prevLoc = [touch ]
if(touch.tapCount == 2)
NSLog(@"tapCount 2");
else if(touch.tapCount == 1)
NSLog(@"tapCount 1");
}
Run Code Online (Sandbox Code Playgroud)
但它总是在 2 次敲击之前检测到 1 次敲击。如何仅检测 1 / 2 次点击?