Lacko
Lacko

Reputation: 79

Disable Delete for 1 Cell in UITableView

I have a UITableView. It pulls information from the address book where needed. I also have the bottom cell programatically made to be a button that loads up the address book.

My problem is when I allow the user to delete a row by swiping right, it shows it for the last cell I have made as a button. Is there a way to not allow a delete function showing on just 1 cell?

Upvotes: 0

Views: 349

Answers (2)

omz
omz

Reputation: 53551

Implement tableView:canEditRowAtIndexPath: in the table view's dataSource and return NO for the row you don't want to be deletable.

Upvotes: 2

Sulthan
Sulthan

Reputation: 130082

You have to implement [UITableViewDelegate tableView:editingStyleForRowAtIndexPath:] and return UITableViewCellEditingStyleDelete only for the cells that can be deleted. Return UITableViewCellEditingStyleNone for the cells that can't be deleted.

Upvotes: 0

Related Questions