mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-03 20:46:28 +00:00
Tableviews: fix edition/suppression of items in table views with checkboxes
This commit is contained in:
parent
9e600af7d7
commit
ef90322429
2 changed files with 13 additions and 3 deletions
|
|
@ -123,12 +123,16 @@
|
|||
logs = ms_list_next(logs);
|
||||
}
|
||||
|
||||
[self computeSections];
|
||||
|
||||
[super loadData];
|
||||
}
|
||||
|
||||
- (void)computeSections {
|
||||
NSArray *unsortedDays = [self.sections allKeys];
|
||||
self.sortedDays = [unsortedDays sortedArrayUsingComparator:^NSComparisonResult(NSDate *d1, NSDate *d2) {
|
||||
return ![d1 compare:d2]; // reverse order
|
||||
}];
|
||||
|
||||
[super loadData];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
|
|
@ -207,6 +211,9 @@
|
|||
[[_sections objectForKey:_sortedDays[indexPath.section]] removeObject:log];
|
||||
if (((NSArray *)[_sections objectForKey:_sortedDays[indexPath.section]]).count == 0) {
|
||||
[_sections removeObjectForKey:_sortedDays[indexPath.section]];
|
||||
[tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section]
|
||||
withRowAnimation:UITableViewRowAnimationFade];
|
||||
[self computeSections];
|
||||
}
|
||||
|
||||
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@
|
|||
cell.accessoryType = UITableViewCellAccessoryNone;
|
||||
}
|
||||
_deleteButton.enabled = (_selectedItems.count != 0);
|
||||
_editButton.enabled = YES;
|
||||
}
|
||||
|
||||
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
|
||||
|
|
@ -101,12 +102,14 @@
|
|||
[_selectedItems sortUsingComparator:^(NSIndexPath *obj1, NSIndexPath *obj2) {
|
||||
return [obj2 compare:obj1];
|
||||
}];
|
||||
for (NSIndexPath *indexPath in _selectedItems) {
|
||||
NSArray *copy = [[NSArray alloc] initWithArray:_selectedItems];
|
||||
for (NSIndexPath *indexPath in copy) {
|
||||
[self tableView:self.tableView
|
||||
commitEditingStyle:UITableViewCellEditingStyleDelete
|
||||
forRowAtIndexPath:indexPath];
|
||||
}
|
||||
[_selectedItems removeAllObjects];
|
||||
[self setEditing:NO animated:YES];
|
||||
}
|
||||
|
||||
- (void)onSelectionToggle:(id)sender {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue