Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.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
Iphone 滑动删除_Iphone_Uitableview - Fatal编程技术网

Iphone 滑动删除

Iphone 滑动删除,iphone,uitableview,Iphone,Uitableview,我已经看过了,但似乎在堆栈溢出的任何地方都找不到一个和我有同样问题的地方。因此,我使用以下代码: -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyle

我已经看过了,但似乎在堆栈溢出的任何地方都找不到一个和我有同样问题的地方。因此,我使用以下代码:

  -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete); 
}

当我滑动时,会出现删除按钮,但当按下该按钮时,它没有任何作用,我忘记做什么了?

您需要在
if
语句之后实际删除数据。目前,您的
if
语句没有任何作用,因为它后面只有一个分号

 -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete)
    {
        //Code to delete data goes here.
        //This could include removing an object from an array, deleting it from core data,
        //and removing the selected row.
    }
}

你知道,我本来可以解决这个问题的,但通常情况下,先看看这里会更快。很好,答案很简单,而且效果很好。