diff --git a/RETableViewManager/RETableViewItem.h b/RETableViewManager/RETableViewItem.h index af53f1a..e54c885 100644 --- a/RETableViewManager/RETableViewItem.h +++ b/RETableViewManager/RETableViewItem.h @@ -56,5 +56,6 @@ - (id)initWithTitle:(NSString *)title accessoryType:(UITableViewCellAccessoryType)accessoryType selectionHandler:(void(^)(RETableViewItem *item))selectionHandler accessoryButtonTapHandler:(void(^)(RETableViewItem *item))accessoryButtonTapHandler; - (NSIndexPath *)indexPath; +- (void)reloadRowWithAnimation:(UITableViewRowAnimation)animation; @end diff --git a/RETableViewManager/RETableViewItem.m b/RETableViewManager/RETableViewItem.m index 7d4ecb5..1dee310 100644 --- a/RETableViewManager/RETableViewItem.m +++ b/RETableViewManager/RETableViewItem.m @@ -25,6 +25,7 @@ #import "RETableViewItem.h" #import "RETableViewSection.h" +#import "RETableViewManager.h" @implementation RETableViewItem @@ -79,4 +80,9 @@ return [NSIndexPath indexPathForRow:[self.section.items indexOfObject:self] inSection:self.section.index]; } +- (void)reloadRowWithAnimation:(UITableViewRowAnimation)animation +{ + [self.section.tableViewManager.tableView reloadRowsAtIndexPaths:@[self.indexPath] withRowAnimation:animation]; +} + @end diff --git a/RETableViewManagerExample/RETableViewManagerExample/Classes/Controllers/ControlsViewController.m b/RETableViewManagerExample/RETableViewManagerExample/Classes/Controllers/ControlsViewController.m index 83ac9d3..e4f4569 100644 --- a/RETableViewManagerExample/RETableViewManagerExample/Classes/Controllers/ControlsViewController.m +++ b/RETableViewManagerExample/RETableViewManagerExample/Classes/Controllers/ControlsViewController.m @@ -68,7 +68,8 @@ // RETableViewOptionsController *optionsController = [[RETableViewOptionsController alloc] initWithItem:item options:options multipleChoice:NO completionHandler:^{ [weakSelf.navigationController popViewControllerAnimated:YES]; - [weakSelf.tableView reloadRowsAtIndexPaths:@[item.indexPath] withRowAnimation:UITableViewRowAnimationNone]; + + [item reloadRowWithAnimation:UITableViewRowAnimationNone]; // same as [weakSelf.tableView reloadRowsAtIndexPaths:@[item.indexPath] withRowAnimation:UITableViewRowAnimationNone]; }]; [weakSelf.navigationController pushViewController:optionsController animated:YES]; }]; @@ -86,7 +87,7 @@ // Present options controller // RETableViewOptionsController *optionsController = [[RETableViewOptionsController alloc] initWithItem:item options:options multipleChoice:YES completionHandler:^{ - [weakSelf.tableView reloadRowsAtIndexPaths:@[item.indexPath] withRowAnimation:UITableViewRowAnimationNone]; + [item reloadRowWithAnimation:UITableViewRowAnimationNone]; // same as [weakSelf.tableView reloadRowsAtIndexPaths:@[item.indexPath] withRowAnimation:UITableViewRowAnimationNone]; NSLog(@"%@", item.value); }]; [weakSelf.navigationController pushViewController:optionsController animated:YES];