- (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;
}
}
}
//删除
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:focusRow inSection:focusSection];
[self.tableV0 deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];