Skip to content

Instantly share code, notes, and snippets.

@samrayner
Last active October 13, 2015 19:07
Show Gist options
  • Save samrayner/4241682 to your computer and use it in GitHub Desktop.
Save samrayner/4241682 to your computer and use it in GitHub Desktop.
Select nearest parent UITableViewCell of a view
- (void)selectParentTableViewCell:(UIView *)view
{
//maximum 5 attempts
for(int i = 0; i < 5; i++) {
view = view.superview;
if([view isKindOfClass:[UITableViewCell class]]) {
UITableViewCell *cell = (UITableViewCell *)view;
[self.tableView selectRowAtIndexPath:[self.tableView indexPathForCell:cell] animated:NO scrollPosition:UITableViewScrollPositionNone];
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment