mirror of
https://github.com/zhigang1992/RETableViewManager.git
synced 2026-06-19 01:56:30 +08:00
Differentiate insert and delete styles
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
|
||||
for (NSInteger i = 1; i <= 5; i++) {
|
||||
RETableViewItem *item = [RETableViewItem itemWithTitle:[NSString stringWithFormat:@"Section 1, Item %i", i] accessoryType:UITableViewCellAccessoryNone selectionHandler:nil];
|
||||
item.deletable = YES;
|
||||
item.editingStyle = UITableViewCellEditingStyleDelete;
|
||||
item.deletionHandler = ^(RETableViewItem *item) {
|
||||
NSLog(@"Item removed: %@", item.title);
|
||||
};
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
for (NSInteger i = 1; i <= 5; i++) {
|
||||
RETableViewItem *item = [RETableViewItem itemWithTitle:[NSString stringWithFormat:@"Section 3, Item %i", i] accessoryType:UITableViewCellAccessoryNone selectionHandler:nil];
|
||||
item.deletable = YES;
|
||||
item.editingStyle = UITableViewCellEditingStyleDelete;
|
||||
item.movable = YES;
|
||||
item.moveHandler = ^(RETableViewItem *item, NSIndexPath *sourceIndexPath, NSIndexPath *destinationIndexPath) {
|
||||
NSLog(@"Moved item: %@ from [%i,%i] to [%i,%i]", item.title, sourceIndexPath.section, sourceIndexPath.row, destinationIndexPath.section, destinationIndexPath.row);
|
||||
@@ -71,7 +71,7 @@
|
||||
[section addItem:item];
|
||||
}
|
||||
|
||||
section = [[RETableViewSection alloc] initWithHeaderTitle:@"Can move only within section"];
|
||||
section = [[RETableViewSection alloc] initWithHeaderTitle:@"Can move only within this section"];
|
||||
[_manager addSection:section];
|
||||
|
||||
for (NSInteger i = 1; i <= 5; i++) {
|
||||
@@ -82,6 +82,15 @@
|
||||
};
|
||||
[section addItem:item];
|
||||
}
|
||||
|
||||
section = [[RETableViewSection alloc] initWithHeaderTitle:@"Insert style"];
|
||||
[_manager addSection:section];
|
||||
RETableViewItem *item = [RETableViewItem itemWithTitle:[NSString stringWithFormat:@"Section 5, Item %i", 1] accessoryType:UITableViewCellAccessoryNone selectionHandler:nil];
|
||||
item.insertionHandler = ^(RETableViewItem *item) {
|
||||
NSLog(@"Insertion handler callback");
|
||||
};
|
||||
item.editingStyle = UITableViewCellEditingStyleInsert;
|
||||
[section addItem:item];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user