Skip to content

Instantly share code, notes, and snippets.

View srongch's full-sized avatar

Sronglong srongch

View GitHub Profile
@srongch
srongch / gist:b769fc3572d3dda9592359075caae636
Created March 22, 2019 10:51 — 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;
}