Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save edwardean/e390b1c545a9f6a22a3c4c195cb6905e to your computer and use it in GitHub Desktop.

Select an option

Save edwardean/e390b1c545a9f6a22a3c4c195cb6905e to your computer and use it in GitHub Desktop.
Get the closes view controller to the current view.
@implementation UIView (PSPDFKitAdditions)
- (UIViewController *)pspdf_closestViewController {
UIResponder *responder = self;
while ((responder = [responder nextResponder])) {
if ([responder isKindOfClass:UIViewController.class]) break;
}
return (UIViewController *)responder;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment