Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 滑动可仅通过一个手势删除单元格_Ios_Uitableview - Fatal编程技术网

Ios 滑动可仅通过一个手势删除单元格

Ios 滑动可仅通过一个手势删除单元格,ios,uitableview,Ios,Uitableview,我想通过一个滑动手势删除单元格。问题是当我向左滑动时,会出现删除图标。当然,当我点击删除图标时,单元格将被删除。我想在刷手机后立即删除手机。ios 9支持它吗 更多详细信息 当用户向左滑动到单元格中间时,将显示“删除”按钮。当他将继续滑动到屏幕边缘时,单元格将被删除。为什么没有自定义表格单元格 在单元格上,在内容视图或任何部分添加滑动手势 使用indexpath将其调用委托给tableviewcontroller - (void)someDelegateFunctionToDeleteCellA

我想通过一个滑动手势删除单元格。问题是当我向左滑动时,会出现删除图标。当然,当我点击删除图标时,单元格将被删除。我想在刷手机后立即删除手机。ios 9支持它吗

更多详细信息
当用户向左滑动到单元格中间时,将显示“删除”按钮。当他将继续滑动到屏幕边缘时,单元格将被删除。

为什么没有自定义表格单元格

在单元格上,在内容视图或任何部分添加滑动手势

使用indexpath将其调用委托给tableviewcontroller

- (void)someDelegateFunctionToDeleteCellAtIndexPath:(NSIndexpath *)indexPath{
[dataSourceArray removeObjectAtIndex:indexPath.row];
NSArray *deleteIndexPaths = @[indexPath];
  [tableView beginUpdates];
    [tableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];  
  [tableView endUpdates];
}

为什么没有自定义的表格单元格

在单元格上,在内容视图或任何部分添加滑动手势

使用indexpath将其调用委托给tableviewcontroller

- (void)someDelegateFunctionToDeleteCellAtIndexPath:(NSIndexpath *)indexPath{
[dataSourceArray removeObjectAtIndex:indexPath.row];
NSArray *deleteIndexPaths = @[indexPath];
  [tableView beginUpdates];
    [tableView deleteRowsAtIndexPaths:deleteIndexPaths withRowAnimation:UITableViewRowAnimationFade];  
  [tableView endUpdates];
}

在UITableView上使用UISweep手势:

   - (void)viewDidLoad
   {
    [super viewDidLoad];
    UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:sel
                                                                               action:@selector(leftSwipe:)];
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
    [self.tableView addGestureRecognizer:recognizer];
    }


 - (void)leftSwipe:(UISwipeGestureRecognizer *)gestureRecognizer
        {
             CGPoint location = [gestureRecognizer locationInView:self.tableView];
            NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location]; 
            [dataSourceArray removeObjectAtIndex:indexPath.row];
            [tableView reloadData];
        }

在UITableView上使用UISweep手势:

   - (void)viewDidLoad
   {
    [super viewDidLoad];
    UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:sel
                                                                               action:@selector(leftSwipe:)];
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
    [self.tableView addGestureRecognizer:recognizer];
    }


 - (void)leftSwipe:(UISwipeGestureRecognizer *)gestureRecognizer
        {
             CGPoint location = [gestureRecognizer locationInView:self.tableView];
            NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:location]; 
            [dataSourceArray removeObjectAtIndex:indexPath.row];
            [tableView reloadData];
        }

我试着解决你的问题,很容易就找到了答案

m


以上我的答案非常有效。

我尝试了你问题的解决方案。我很容易得到了解决方案

m


以上我的答案非常有效。

你能解释清楚你的问题吗?@user3182143我更新了我的问题。你能解释清楚你的问题吗?@user3182143我更新了我的问题。