Created
October 25, 2013 23:38
-
-
Save priore/7163469 to your computer and use it in GitHub Desktop.
How to retrieve the current displayed viewcontroller
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
// | |
// how to retrieve the current displayed viewcontroller | |
// | |
+ (UIViewController*)topMostController | |
{ | |
UIViewController *topController = [[UIApplication sharedApplication] keyWindow].rootViewController; | |
while (topController.presentedViewController) { | |
topController = topController.presentedViewController; | |
} | |
return topController; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment