tableview做长按删除

 UILongPressGestureRecognizer *longPressGR = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(lpGR:)];

        //设定最小的长按时间 按不够这个时间不响应手势

        longPressGR.minimumPressDuration=0.7;

        [celladdGestureRecognizer:longPressGR];


#pragma mark -实现手势对应的功能

-(void)lpGR:(UILongPressGestureRecognizer *)lpGR

{

    if (lpGR.state == UIGestureRecognizerStateBegan) {//手势开始

        CGPointpoint = [lpGRlocationInView:self.tableViewNoticeDetails];

        NSIndexPath*indexPath =  [self.tableViewNoticeDetailsindexPathForRowAtPoint:point];

        if(indexPath !=nil){

            NSIntegerindexNum = indexPath.row;

            NSLog(@"点击的是第%ld行",(long)indexNum);

        }

    }

    if (lpGR.state == UIGestureRecognizerStateEnded){

        //手势结束

        [self longPressDelete];//添加弹窗

    }

}

-(void)longPressDelete

{

    ACActionSheet *actionSheet = [[ACActionSheet alloc] initWithTitle:nil cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@[@"删除"] actionSheetBlock:^(NSInteger buttonIndex) {

        if(buttonIndex ==0) {

        }

    }];

    [actionSheetshow];

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容