Skip to content

Instantly share code, notes, and snippets.

@ManWithBear
Created November 30, 2016 15:58
Show Gist options
  • Save ManWithBear/452e2b2b846f42314652210754581e93 to your computer and use it in GitHub Desktop.
Save ManWithBear/452e2b2b846f42314652210754581e93 to your computer and use it in GitHub Desktop.
Find first tableView in hierarchy
- (UITableView *)parentTableView {
// iterate up the view hierarchy to find the table containing this cell/view
UIView *aView = self.superview;
while(aView != nil) {
if([aView isKindOfClass:[UITableView class]]) {
return (UITableView *)aView;
}
aView = aView.superview;
}
return nil; // this view is not within a tableView
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment