Reputation: 690
In my application i have added gesture and these method
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
UILongPressGestureRecognizer *longpress =[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handellongpress:)];
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *start = [[event allTouches] anyObject];
CGPoint StartPoint = [start locationInView:self.view];
NSLog(@"start points x : %f y : %f", StartPoint.x, StartPoint.y);
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *move = [[event allTouches] anyObject];
CGPoint MovePoint = [move locationInView:self.view];
NSLog(@"MovePoint x : %f y : %f", MovePoint.x, MovePoint.y);
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *end = [[event allTouches] anyObject];
CGPoint EndPoint = [end locationInView:self.view];
NSLog(@"end ponts x : %f y : %f", EndPoint.x, EndPoint.y);
}
-(void)handellongpress:(UITapGestureRecognizer *)recognizer {
CGPoint LongTapPoint = [recognizer locationInView:self.view];
NSLog(@"LongTapPoint.x %f,LongTapPoint.y %f",LongTapPoint.x,LongTapPoint.y);
}
- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer {
CGPoint SingleTap = [recognizer locationInView:self.view];
NSLog(@"SingleTap.x %f,SingleTap.y %f",SingleTap.x,SingleTap.y);
}
- (void)handleDoubleTap:(UITapGestureRecognizer *)recognizer {
CGPoint doubleTapPoint = [recognizer locationInView:self.view];
NSLog(@"doubleTapPoint.x %f,doubleTapPoint.y %f",doubleTapPoint.x,doubleTapPoint.y);
}
Now what i want is user touch down in a certain place, drag across to a new place, then hold in place for a while how to detect that last location. i m facing a problem in which if the user start there swipe from button location touchMove and touchEnd location method dint get called. how to call touchEnd method in longpress.
Upvotes: 2
Views: 2566
Reputation: 11
if(gestureRecognizer.state == UIGestureRecognizerStateBegan)
{
NSLog(@"UIGestureRecognizerStateBegan");
}
else if(gestureRecognizer.state == UIGestureRecognizerStateEnded)
{
NSLog(@"UIGestureRecognizerStateEnded");
}
else if(gestureRecognizer.state == UIGestureRecognizerStateChanged)
{
NSLog(@"UIGestureRecognizerStateChanged");
}
else if(gestureRecognizer.state == UIGestureRecognizerStateCancelled)
{
NSLog(@"UIGestureRecognizerStateCancelled");
}
else if(gestureRecognizer.state ==UIGestureRecognizerStateFailed )
{
NSLog(@"UIGestureRecognizerStateFailed");
}
use gestureRecogizer.state
Upvotes: 1