Long Touch Recognizer


/ Published in: Objective C
Save to your folder(s)

Detect long touches on any UIView


Copy this code and paste it in your HTML
  1. UILongPressGestureRecognizer *lpHandler = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandler:)];
  2. lpHandler.minimumPressDuration = 0.5; //seconds
  3. lpHandler.delegate = self;
  4. [uiTableView addGestureRecognizer:lpHandler];
  5. [lpHandler release];
  6. ···
  7. -(void)longPressHandler:(UILongPressGestureRecognizer *)gestureRecognizer
  8. {
  9. CGPoint p = [gestureRecognizer locationInView:self.tableView];
  10. NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:p];
  11. if (indexPath == nil)
  12. NSLog(@"long press on table view");
  13. else
  14. NSLog(@"long press on row %d", indexPath.row);
  15. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.