滑动即可删除

Ale*_*ott 5 iphone uitableview

我看了,我似乎无法找到堆栈上的任何地方溢出一些与我有同样问题的人.所以我使用以下代码:

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

当我滑动删除按钮出现,但按下时它没有做任何事情,我忘了做什么?

Gen*_*ari 10

您需要在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.
    }
}
Run Code Online (Sandbox Code Playgroud)