Skip to content

Instantly share code, notes, and snippets.

@sajjadsarkoobi
sajjadsarkoobi / gist:4cb1fb9acb318ec9d00c7dce96eeaceb
Created March 14, 2018 09:16 — forked from snikch/gist:3661188
Find the current top view controller for your iOS application
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}