/ Published in: Objective C

Detect long touches on any UIView
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
UILongPressGestureRecognizer *lpHandler = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandler:)]; lpHandler.minimumPressDuration = 0.5; //seconds lpHandler.delegate = self; [uiTableView addGestureRecognizer:lpHandler]; [lpHandler release]; ··· -(void)longPressHandler:(UILongPressGestureRecognizer *)gestureRecognizer { CGPoint p = [gestureRecognizer locationInView:self.tableView]; if (indexPath == nil) NSLog(@"long press on table view"); else NSLog(@"long press on row %d", indexPath.row); }
Comments
