cell上添加长按手势并传参

2018-06-26  本文已影响0人  梁苏珍

   cell.contentView.tag= indexPath.row;

    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longTapAction:)];

    longPress.minimumPressDuration = 0.8; //定义按的时间

    longPress.numberOfTouchesRequired = 1;

    longPress.view.tag= indexPath.row;

    [cell.contentView addGestureRecognizer:longPress];

- (void) longTapAction:(UILongPressGestureRecognizer*)longPress {

    NSLog(@"%ld>>>>>>>>>tag",(long)longPress.view.tag);

    if (longPress.state == UIGestureRecognizerStateBegan) {

        NSLog(@"long pressTap state :begin执行2次");

        [self promptIfTheMessageDeleted:longPress.view.tag];

    }else{

        NSLog(@"long pressTap state :end执行1次");//

    }

}

上一篇下一篇

猜你喜欢

热点阅读