标签:
1、添加手势识别事件、按住时长、处理函数
UILongPressGestureRecognizer * longPressGr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressToDo:)];
longPressGr.minimumPressDuration = 0.8;
[self.tableView addGestureRecognizer:longPressGr];
[longPressGr release];
2、实现UIAlertView 的代理方法(如果需要弹出提示)
- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
3、实现处理函数
longPressToDo:
通过点击的坐标来判断点击了哪一个cell
if(gesture.state == UIGestureRecognizerStateBegan)
{
CGPoint point = [gesture locationInView:self.tableView];
NSIndexPath * indexPath = [self.tableView indexPathForRowAtPoint:point];
if(indexPath == nil) return ;
}
标签:
原文地址:http://www.cnblogs.com/wangbaixue/p/5220998.html