Skip to content

Instantly share code, notes, and snippets.

View danmartyn's full-sized avatar

Daniel Martyn danmartyn

  • Ceridian
  • Canada
View GitHub Profile
@danmartyn
danmartyn / longPress
Created May 28, 2013 04:23
Handle Long Press
- (void)handleLongPress:(UILongPressGestureRecognizer*)sender {
if (sender.state == UIGestureRecognizerStateEnded) {
NSLog(@"UIGestureRecognizerStateEnded");
//Do Whatever You want on End of Gesture
}
else if (sender.state == UIGestureRecognizerStateBegan){
NSLog(@"UIGestureRecognizerStateBegan.");
//Do Whatever You want on Began of Gesture
}
}
// Create a UITapGestureRecognizer and add it to the view
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
tap.cancelsTouchesInView = NO;
[self.view addGestureRecognizer:tap];
// In the handleTap Method add
- (void)handleTap:(UITapGestureRecognizer *)tap
{
[self.view endEditing:YES];
}