Warrior
Warrior

Reputation: 39374

How to limit the delete option for first row in UITableView

HI In my appliacation I want deletion control button will not work for first row except for all other rows.

Please can anybody tell me how it would be possible.

Thanks

Upvotes: 1

Views: 187

Answers (1)

Vladimir
Vladimir

Reputation: 170839

Implement editingStyleForRowAtIndexPath method in table delegate and return style value depending on cell's index:

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
           editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
    //Disable editing for 1st row in section
    return (indexPath.row == 0) ? UITableViewCellEditingStyleNone : UITableViewCellEditingStyleDelete;
}

Upvotes: 3

Related Questions