iOS delete a tableview row

前端 未结 6 1196
北荒
北荒 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:50

    Use the tableview commiteditingstyle method to delete a cell/row of the tableviewcontroller.

    Here is the workable code snip:

    -(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
    
    {
    
        [ArrayHoldsCellObj removeObjectAtIndex:indexPath.row];
    
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
    }
    

    Note that the ArrayHoldsCellObj is the Array object you must declare and assign each cell to the area index.

提交回复
热议问题