From 01b727804bcd522aa92cf78771a13cabb07dfda5 Mon Sep 17 00:00:00 2001 From: Roman Efimov Date: Tue, 4 Jun 2013 10:38:02 -0500 Subject: [PATCH] Add show less item --- .../Classes/Controllers/RetractableViewController.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/RETableViewManagerExample/RETableViewManagerExample/Classes/Controllers/RetractableViewController.m b/RETableViewManagerExample/RETableViewManagerExample/Classes/Controllers/RetractableViewController.m index b719a97..8b5c301 100644 --- a/RETableViewManagerExample/RETableViewManagerExample/Classes/Controllers/RetractableViewController.m +++ b/RETableViewManagerExample/RETableViewManagerExample/Classes/Controllers/RetractableViewController.m @@ -32,6 +32,13 @@ [weakSelf.section addItemsFromArray:expandedItems]; [weakSelf.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic]; }]; + + RETableViewItem *showLessItem = [RETableViewItem itemWithTitle:@"Show Less" accessoryType:UITableViewCellAccessoryDisclosureIndicator selectionHandler:^(RETableViewItem *item) { + [weakSelf.tableView deselectRowAtIndexPath:item.indexPath animated:YES]; + [weakSelf.section removeAllItems]; + [weakSelf.section addItemsFromArray:collapsedItems]; + [weakSelf.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic]; + }]; } @end