iOS delete a tableview row

前端 未结 6 1190
北荒
北荒 2020-12-03 23:14

I had my app working fine on iOS 6. With the upgrade I stopped being able to delete rows from my UITableView.

I\'ve a button in my prototype cell.

6条回答
  •  情歌与酒
    2020-12-03 23:54

    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
    //add code here for when you hit delete
    [dataSourceArray removeObjectAtIndex:indexPath.row];
    [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
    
    }    
    }
    

提交回复
热议问题