UIGestureRecognizer水龙头和删除

问题描述:

我有一个UILongPressGestureRecognizer火灾的方法-(void)didPress。当前视图默认为UIImagedidPress使UIImage消失在屏幕上。但是,只要用户仍然很长时间按下,图像就只能从屏幕上消失。一旦用户放开最初的长按,图像会再次出现。我的代码已经可以处理最初的长按,但我不确定如何确定用户何时放弃了长时间的触摸。UIGestureRecognizer水龙头和删除

您应该通过UILongPressGestureRecognizer到你的方法,并检查姿态,状态当用户释放他的手指/手指在屏幕中,它会发送UIGestureRecognizerStateEnded

- (void)didPress:(UILongPressGestureRecognizer *)recognizer { 
    if (recognizer.state == UIGestureRecognizerStateBegan) { 
    NSLog(@"Started"); 
    } 
    if (recognizer.state == UIGestureRecognizerStateEnded) { 
    NSLog(@"Finished");  
    } 
} 

的状态下使用的touchesBegan: withEvent:早在UIGestureRecognizer的

之前