I'm catching touch events. I need to differentiate two events 1) User touched a screen and then lifted a finger 2) User touched screen and don't lifted a finger How can I differentiate two events?
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
if (isFirstCase)
{}
if (isSecondCase)
{}
}
Attribute (NSSet *)touches
contains UITouch
objects each of them contain several helpful properties:
@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;
Phase and tapCount is very usable property to identify the type of touch.
Check if you can use UIGestureRecognizers. NSArray *gestureRecognizers
- the array of this objects which related to this particular touch.
Have a nice day :)