我正在抓触摸事件。我需要区分两个事件
1)用户触摸屏幕然后松开手指
2)用户触摸屏幕但不松开手指
如何区分两个事件?
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
if (isFirstCase)
{}
if (isSecondCase)
{}
}
最佳答案
(NSSet *)touches
属性包含UITouch
对象,每个对象都包含几个有用的属性:
@property(nonatomic, readonly) NSUInteger tapCount
@property(nonatomic, readonly) NSTimeInterval timestamp
@property(nonatomic, readonly) UITouchPhase phase
@property(nonatomic,readonly,copy) NSArray *gestureRecognizers
typedef enum {
UITouchPhaseBegan,
UITouchPhaseMoved,
UITouchPhaseStationary,
UITouchPhaseEnded,
UITouchPhaseCancelled,
} UITouchPhase;
相位和tapCount是用于识别触摸类型的非常有用的属性。
检查是否可以使用UIGestureRecognizers。
NSArray *gestureRecognizers
-与此特定触摸相关的此对象的数组。祝你今天愉快 :)
关于ios - 我需要区分两个触摸事件。如何区分两个事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9885681/