Rafay Hasan Rafay Hasan - 4 months ago 18
iOS Question

Delete a tableview cell by tapping the red minus icon in iOS

I want to delete the tableview cell right away without the confirmation of red "Delete" button press when user clicks the red minus icon.
Steps 1. Hit edit button > red minus icon appears > hit the minus icon >> row deleted without showing the red "Delete" icon.

Answer

This does the work you want.

- (nullable NSString *)tableView:(UITableView *)tableViews titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath 
{
[arrOutputRecords removeObjectAtIndex:indexPath.row];

[tableViews deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                  withRowAnimation:YES];

[_tableView reloadData];

return @"";
}
Comments