Add ability to assign actions for accessoryButton

This commit is contained in:
Roman Efimov
2013-03-27 16:23:27 -05:00
parent 44118c9c3a
commit cb2cec9cf5
7 changed files with 53 additions and 21 deletions

View File

@@ -54,17 +54,21 @@
section = [[RETableViewSection alloc] initWithHeaderTitle:@"Accessories"];
[_manager addSection:section];
[section addItem:[REStringItem itemWithTitle:@"Accessory 1" actionBlock:^(RETableViewItem *item) {
[section addItem:[REStringItem itemWithTitle:@"Accessory 1" accessoryType:UITableViewCellAccessoryDisclosureIndicator actionBlock:^(RETableViewItem *item) {
[weakSelf.tableView deselectRowAtIndexPath:item.indexPath animated:YES];
} accessoryType:UITableViewCellAccessoryDisclosureIndicator]];
}]];
[section addItem:[REStringItem itemWithTitle:@"Accessory 2" actionBlock:^(RETableViewItem *item) {
REStringItem *accessoryItem2 = [REStringItem itemWithTitle:@"Accessory 2" accessoryType:UITableViewCellAccessoryDetailDisclosureButton actionBlock:^(RETableViewItem *item) {
[weakSelf.tableView deselectRowAtIndexPath:item.indexPath animated:YES];
} accessoryType:UITableViewCellAccessoryDetailDisclosureButton]];
}];
accessoryItem2.accessoryButtonActionBlock = ^(RETableViewItem *item) {
NSLog(@"Accessory button in accessoryItem2 was tapped");
};
[section addItem:accessoryItem2];
[section addItem:[REStringItem itemWithTitle:@"Accessory 2" actionBlock:^(RETableViewItem *item) {
[section addItem:[REStringItem itemWithTitle:@"Accessory 2" accessoryType:UITableViewCellAccessoryCheckmark actionBlock:^(RETableViewItem *item) {
[weakSelf.tableView deselectRowAtIndexPath:item.indexPath animated:YES];
} accessoryType:UITableViewCellAccessoryCheckmark]];
}]];
// Set delegate and datasource
//

View File

@@ -30,13 +30,13 @@
RETableViewSection *section = [[RETableViewSection alloc] init];
[_manager addSection:section];
[section addItem:[REStringItem itemWithTitle:@"Forms" actionBlock:^(RETableViewItem *item) {
[section addItem:[REStringItem itemWithTitle:@"Forms" accessoryType:UITableViewCellAccessoryDisclosureIndicator actionBlock:^(RETableViewItem *item) {
[weakSelf.navigationController pushViewController:[[ControlsViewController alloc] initWithStyle:UITableViewStyleGrouped] animated:YES];
} accessoryType:UITableViewCellAccessoryDisclosureIndicator]];
}]];
[section addItem:[REStringItem itemWithTitle:@"List" actionBlock:^(RETableViewItem *item) {
[section addItem:[REStringItem itemWithTitle:@"List" accessoryType:UITableViewCellAccessoryDisclosureIndicator actionBlock:^(RETableViewItem *item) {
[weakSelf.navigationController pushViewController:[[ListViewController alloc] initWithStyle:UITableViewStylePlain] animated:YES];
} accessoryType:UITableViewCellAccessoryDisclosureIndicator]];
}]];
// Set delegate and datasource
//