How can I detect a double tap on a certain cell in UITableView?

后端 未结 14 1021
悲哀的现实
悲哀的现实 2020-12-01 00:18

How can I detect a double tap on a certain cell in UITableView?

i.e. I want to perform one action if the user made a single touch and a

14条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 00:38

    Improvement for oxigen answer.

    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch *touch = [touches anyObject];
        if(touch.tapCount == 2) {
            CGPoint touchPoint = [touch locationInView:self];
            NSIndexPath *touchIndex = [self indexPathForRowAtPoint:touchPoint];
            if (touchIndex) {
                // Call some callback function and pass 'touchIndex'.
            }
        }
        [super touchesEnded:touches withEvent:event];
    }
    

提交回复
热议问题