Thursday, October 20, 2011

Swipe to delete from UITable view

In order to achieve swipe to delete option use following code snippet:

#pragma for deleting element from tableview

-(void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
   
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if(editingStyle == UITableViewCellEditingStyleDelete) {
        [Array2 removeObjectAtIndex:indexPath.row];
        [Array1 removeObjectAtIndex:indexPath.row];
        [TableName_obj reloadData];
    }
}