Skip to content
Blog iOS: UITableView – Swipe to delete row

iOS: UITableView – Swipe to delete row

Swipe-to-Delete feature shows a “Delete” button when a user swipes horizontally across a row.

swipe to delete

To enable the swipe-to-delete feature of table views, you must implement the tableView:commitEditingStyle:forRowAtIndexPath: method.
Add the following code to enable the swipe-to-delete feature.

- (void)tableView:(UITableView *)tableView 
	forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        //add code here to do what you want when you hit delete
        [itemArray removeObjectAtIndex:[indexPath row]];
        [tableView reloadData];

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.