Created
November 24, 2014 00:04
-
-
Save hugo53/6598af5190804bd727e6 to your computer and use it in GitHub Desktop.
Get view controller of a view
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
UIViewController *viewController; | |
for (UIView* next = [self superview]; next; next = next.superview) { | |
UIResponder* nextResponder = [next nextResponder]; | |
if ([nextResponder isKindOfClass:[UIViewController class]]) { | |
viewController = (UIViewController*)nextResponder; | |
} | |
} | |
return viewController; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment