tableviewcell长按删除行

来源:互联网 发布:linux装mysql数据库 编辑:程序博客网 时间:2024/06/05 05:42

- (void)viewDidLoad

{

//给cell加长按手势

UILongPressGestureRecognizer *gestureLongPress = [[UILongPressGestureRecognizeralloc]initWithTarget:selfaction:@selector(gestureLongPress:)];

gestureLongPress.minimumPressDuration =1;

[self.tableV0addGestureRecognizer:gestureLongPress];

[gestureLongPressrelease];

}




#pragma mark - 长按手势


- (void)gestureLongPress:(UILongPressGestureRecognizer *)gestureRecognizer

{

   CGPoint tmpPointTouch = [gestureRecognizer locationInView:self.tableV0];

   if (gestureRecognizer.state ==UIGestureRecognizerStateBegan) {

       NSIndexPath *indexPath = [self.tableV0indexPathForRowAtPoint:tmpPointTouch];

       if (indexPath == nil) {

            NSLog(@"not tableView");

        }else{

           focusSection = [indexPath section];

           focusRow = [indexPath row];

            

           NSLog(@"%d",focusSection);

           NSLog(@"%d",focusRow);

            

            

           deletebtn.hidden =NO;

        }

    }

}

0 0
原创粉丝点击