码迷,mamicode.com
首页 > 其他好文 > 详细

tableview长按响应的实现

时间:2016-02-26 18:34:59      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:

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 ;

}

 

tableview长按响应的实现

标签:

原文地址:http://www.cnblogs.com/wangbaixue/p/5220998.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!