美文网首页
cell上添加长按手势并传参

cell上添加长按手势并传参

作者: 梁苏珍 | 来源:发表于2018-06-26 15:07 被阅读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次");//

        }

    }

    相关文章

      网友评论

          本文标题:cell上添加长按手势并传参

          本文链接:https://www.haomeiwen.com/subject/trqmyftx.html