UITableViewCell 的长按事件处理
今天做任务的时候遇到了UITableViewCell的长按处理,比如按住一秒之后触发事件。刚开始本想自定义cell,然后在里面捕捉touch事件,touchbegin后开始计时,超过一秒触发事件,不过想想如此有点麻烦,然后查下了orgnizer,发现了
UILongPressGestureRecogn
UILongPressGestureRecogn
initWithTarget:self action:@selector(handleLongPress:)];
longPressReger.minimumPressDuration = 1.0;
[myTableView addGestureRecognizer:longPressReger];
[longPressReger release];
-(void)handleLongPress:(UILongPressGestureRecogn
{
CGPoint point = [gestureRecognizer locationInView:myTableView];
if(gestureRecognizer.state == UIGestureRecognizerState
{
}
else if(gestureRecognizer.state == UIGestureRecognizerState
{
}
else if(gestureRecognizer.state == UIGestureRecognizerState
{
}
NSIndexPath *indexPath = [myTableView indexPathForRowAtPoint:point];
if (indexPath == nil)
NSLog(@”not tableView”);
else
{
focusRow = [indexPath row];
focusView.hidden = NO;
}
}
posted on 2012-05-24 10:12 tongdengquan 阅读(387) 评论(0) 编辑 收藏 举报
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步