简体   繁体   中英

UITableView certain rows not editable

I've configured a UITableView to be editable. For some reason, when the edit button is pressed, only certain rows are actually editable.

Not all of the red, tappable circles used to delete a row are tappable.

Here is a Quicktime video demonstrating the problem .

The same behavior occurs if you swipe the row to delete it (instead of starting with the edit button at the top) - some rows are editable; some are no.

Here is the sequence of events under which I encounter this situation: 1. Populate the tableview (with, say, 2 items) 2. Delete both items 3. Add five items 4. Three of these items will be deletable - the other two (equal to the number initially populating the table) will not be deletable.

I'm a little perplexed. Any help would be very much appreciated. Thanks!

Try to add this to class, when you implement eatable view delegate:

- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
automaticEditControlsDidShow = NO;
[super setEditing:editing animated:animated];

if (editing) {
    automaticEditControlsDidShow = YES;
    [self.tableView insertRowsAtIndexPaths:addRow withRowAnimation:UITableViewRowAnimationLeft];
} else {
    [self.tableView deleteRowsAtIndexPaths:addRow withRowAnimation:UITableViewRowAnimationLeft];
}
}

Or try to implement your editingStyleForRowAtIndexPath method. For Example:

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {

return UITableViewCellEditingStyleDelete;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM