Posted By

ramonprades on 03/20/11


Tagged

gestures


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

athanhcong
Tintenklecks
cnathan


Long Touch Recognizer


 / Published in: Objective C
 

Detect long touches on any UIView

  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  

You need to login to post a comment.