Skip to content

Instantly share code, notes, and snippets.

View vml933's full-sized avatar

Mark Lin vml933

View GitHub Profile
@vml933
vml933 / gist:adf18de833080d399c4c0505f8b77a18
Created January 15, 2018 12:50 — 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;
}