2009-11-09

How to delete a row from a table in an iPhone application

Override the following delegate method as follows.

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{

NSUInteger rowNumber = [indexPath row];

[self.array removeObjectAtIndex: rowNumber];

[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

}

No comments: