Skip to content

Instantly share code, notes, and snippets.

@priore
Created October 25, 2013 23:38
Show Gist options
  • Save priore/7163469 to your computer and use it in GitHub Desktop.
Save priore/7163469 to your computer and use it in GitHub Desktop.
How to retrieve the current displayed viewcontroller
//
// 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