//像这种控件的长按事件有些地方是有系统自带的。但有些时候用起来也不太方便。下面这个可能以后能用到 UILongPressGestureRecognizer *longPressReger = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; longPressReger.minimumPressDuration = 2.0; [tbv addGestureRecognizer:longPressReger]; [longPressReger release]; -(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer { NSLog(@"wwwwwfffffff"); CGPoint point = [gestureRecognizer locationInView:tbv]; if(gestureRecognizer.state == UIGestureRecognizerStateBegan) { NSLog(@"ssseeeeee"); } else if(gestureRecognizer.state == UIGestureRecognizerStateEnded) { NSLog(@"mimimimimimi"); } else if(gestureRecognizer.state == UIGestureRecognizerStateChanged) { NSLog(@"lostllllllll"); } NSIndexPath *indexPath = [tbv indexPathForRowAtPoint:point]; if (indexPath == nil) { NSLog(@"sadfasdfasdf"); } else { //focusRow = [indexPath row]; //focusView.hidden = NO; } }
转载于:https://www.cnblogs.com/qingjoin/archive/2012/10/31/2747710.html
长按事件处理
本文介绍了一种使用UILongPressGestureRecognizer实现长按事件处理的方法。通过设置minimumPressDuration属性,可以控制长按的时间阈值。当长按事件开始、变化或结束时,分别执行不同的操作,如打印日志或获取被点击的单元格indexPath。
581

被折叠的 条评论
为什么被折叠?



