I know about using setEditing:
to enable the editing mode of UITableView.
But I prefer to disable the operation for some certain rows (enable other rows).
Is it possible?
Thanks,
interdev
So, to remove a cell from a table view you first remove it from your data source, then you call deleteRows(at:) on your table view, providing it with an array of index paths that should be zapped. You can create index paths yourself, you just need a section and row number.
When you want to handle deleting, you have to do three things: first, check that it's a delete that's happening and not an insert (this is down to how you use the UI); second, delete the item from the data source you used to build the table; and third, call deleteRows(at:) on your table view.
Implement the -tableView:canEditRowAtIndexPath:
method in your data source. Return NO
for those rows.
this post sum it up perfectly, Is there any way to hide "-" (Delete) button while editing UITableView
in case you don't want to read the post the gist is on the row you don't want to delete but want to allow move row: set edit style for row to UITableViewCellEditingStyleNone
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
return UITableViewCellEditingStyleNone;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With