Created
March 26, 2014 15:05
-
-
Save prendio2/9785467 to your computer and use it in GitHub Desktop.
Custom viewWillApear to restore selected row when transition is cancelled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewWillAppear:(BOOL)animated | |
{ | |
[super viewWillAppear:animated]; | |
NSIndexPath *selectedRowIndexPath = [self.tableView indexPathForSelectedRow]; | |
if (selectedRowIndexPath) { | |
[self.tableView deselectRowAtIndexPath:selectedRowIndexPath animated:YES]; | |
[[self transitionCoordinator] notifyWhenInteractionEndsUsingBlock:^(id<UIViewControllerTransitionCoordinatorContext> context) { | |
if ([context isCancelled]) { | |
[self.tableView selectRowAtIndexPath:selectedRowIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone]; | |
} | |
}]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One tweak you may wish to do, is only kick in this logic
if (self.clearsSelectionOnViewWillAppear)