Created
March 26, 2015 09:16
-
-
Save GuillaumeJasmin/5bc7e91b9b5d1e9ef4e6 to your computer and use it in GitHub Desktop.
panGesture iOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* listener for pan gesture | |
*/ | |
- (void)panListener | |
{ | |
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panHandler:)]; | |
[self.view addGestureRecognizer:panGestureRecognizer]; | |
} | |
/** | |
* trigger on touch move | |
*/ | |
-(void)panHandler:(UIPanGestureRecognizer *)panGestureRecognizer | |
{ | |
CGPoint touchLocation = [panGestureRecognizer locationInView:self.view]; | |
// begin | |
if (panGestureRecognizer.state == UIGestureRecognizerStateBegan) { | |
NSLog(@"Begin touch"); | |
NSLog(@"Begin pos x %f", touchLocation.x); | |
NSLog(@"Begin pos y %f", touchLocation.y); | |
} else if (panGestureRecognizer.state == UIGestureRecognizerStateEnded || panGestureRecognizer.state == UIGestureRecognizerStateFailed || panGestureRecognizer.state == UIGestureRecognizerStateCancelled) { | |
NSLog(@"end touch"); | |
} else { | |
NSLog(@"current pos x %f", touchLocation.x); | |
NSLog(@"current pos y %f", touchLocation.y); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment