开发者

Swipe to delete

开发者 https://www.devze.com 2023-02-02 09:44 出处:网络
I\'ve looked and i can\'t seem to find an开发者_如何学Goy where on stack overflow some one that has had the same problem as me. So I use the following code:

I've looked and i can't seem to find an开发者_如何学Goy where on stack overflow some one that has had the same problem as me. So I use the following code:

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

and when i swipe the delete button appears, but when pressed it doesn't do anything, what have i forgotten to do?


You need to actually delete your data after the if statement. Currently, your if statement does nothing at all, because it just has a semi-colon after it.

 -(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.
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消