0

Ha ii everybody i have a tableview ,when i click the cell it popups a view,its work fine for me,but my question is, i want to tap for 2 second to popup appear.that is ,if i tap the cell for 2 second then only the popup appers.Is that possible?How can i do this?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self.view addSubview:MainPopupView];
//MainPopView is the popup that i want to display after2 minit
}

Thanks in advance.

ICoder
  • 1,347
  • 2
  • 13
  • 23

1 Answers1

1

Give the UILongPressGestureRecognizer a try. You can set the minimumPressDuration to set the time for the gesture to be recognized.

You can add UILongPressGestureRecognizer to your table view cell and get the desired action.

Update Please take a look at this previous SO question How can I determine if a user has pressed on a UITableViewCell for 2 seconds?

Community
  • 1
  • 1
visakh7
  • 26,380
  • 8
  • 55
  • 69
  • i know the class refrence of longtapgesture,but how can i implement in the didselectrowatindexpath?thnks. – ICoder Dec 01 '11 at 07:21
  • See of this previous SO question http://stackoverflow.com/questions/3924446/long-press-on-uitableview/3924965#3924965 gives you a starting point – visakh7 Dec 01 '11 at 07:23
  • i have this code and where to put my popup show code tot his code?-(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer { CGPoint p = [gestureRecognizer locationInView:table]; NSIndexPath *indexPath = [table indexPathForRowAtPoint:p]; if (indexPath == nil) NSLog(@"long press on table view but not on a row"); else NSLog(@"long press on table view at row %d", indexPath.row); } – ICoder Dec 01 '11 at 08:57