Differentiate insert and delete styles

This commit is contained in:
Roman Efimov
2013-04-17 11:59:22 -05:00
parent 959a82fbb5
commit c2421d440b
3 changed files with 23 additions and 9 deletions

View File

@@ -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