user4234
user4234

Reputation: 1527

When editing UITableView how to prevent that delete button from poping out?

Usually when user click delete button in edit mode of UITableView a delete button will pop up asking for confirmation.

I don't want that.

How do I get rid that confirmation ritual?

enter image description here

I want my delete button to work like the plus button. Just add. Just delete. No need to confirm. At least not when the stake is low like in one issue of my program where deleting will simply flag the table to be invisible when out of edit mode.

Upvotes: 3

Views: 644

Answers (2)

El Tomato
El Tomato

Reputation: 6707

What is your data source? If it's an array, why don't you remove the selected item from the array and then refresh the uitableview?

Upvotes: 2

JOM
JOM

Reputation: 8207

Delete confirmation popup is not built into UITableView or UITableViewCell (swipe to delete functionality). Such a thing has to be manually added, therefore getting rid of it is easy: don't add a popup :)

If you are maintaining someone else's code, search for this method:

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    return isEditable ? YES : NO;
}

Method documentation says:

The method permits the delegate to exclude individual rows from being treated as editable. Editable rows display the insertion or deletion control in their cells. If this method is not implemented, all rows are assumed to be editable. Rows that are not editable ignore the editingStyle property of a UITableViewCell object and do no indentation for the deletion or insertion control. Rows that are editable, but that do not want to have an insertion or remove control shown, can return UITableViewCellEditingStyleNone from the tableView:editingStyleForRowAtIndexPath: delegate method.

Here's a link to Apple docs Inserting and Deleting Rows and Sections for more complicated cases.

Upvotes: 5

Related Questions