mirror of
https://github.com/zhigang1992/RETableViewManager.git
synced 2026-06-13 01:28:58 +08:00
Ability to set deletionHanlder without completion
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
@property (copy, readwrite, nonatomic) void (^accessoryButtonTapHandler)(id item);
|
||||
@property (assign, readwrite, nonatomic) BOOL movable;
|
||||
@property (copy, readwrite, nonatomic) void (^insertionHandler)(id item);
|
||||
@property (copy, readwrite, nonatomic) void (^deletionHandler)(id item);
|
||||
@property (copy, readwrite, nonatomic) void (^deletionHandlerWithCompletion)(id item, void (^)(void));
|
||||
@property (copy, readwrite, nonatomic) void (^moveHandler)(id item, NSIndexPath *sourceIndexPath, NSIndexPath *destinationIndexPath);
|
||||
@property (copy, readwrite, nonatomic) BOOL (^allowNewIndexPath)(NSIndexPath *newIndexPath);
|
||||
|
||||
@@ -241,6 +241,8 @@
|
||||
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
|
||||
});
|
||||
} else {
|
||||
if (item.deletionHandler)
|
||||
item.deletionHandler(item);
|
||||
[section.items removeObjectAtIndex:indexPath.row];
|
||||
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
|
||||
}
|
||||
|
||||
@@ -40,9 +40,8 @@
|
||||
for (NSInteger i = 1; i <= 5; i++) {
|
||||
RETableViewItem *item = [RETableViewItem itemWithTitle:[NSString stringWithFormat:@"Section 1, Item %i", i] accessoryType:UITableViewCellAccessoryNone selectionHandler:nil];
|
||||
item.editingStyle = UITableViewCellEditingStyleDelete;
|
||||
item.deletionHandlerWithCompletion = ^(RETableViewItem *item, void (^completion)(void)) {
|
||||
item.deletionHandler = ^(RETableViewItem *item) {
|
||||
NSLog(@"Item removed: %@", item.title);
|
||||
completion();
|
||||
};
|
||||
[section addItem:item];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user