Skip to content

Instantly share code, notes, and snippets.

@billinghamj
Forked from MartinMoizard/gist:6537467
Last active December 24, 2015 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billinghamj/6723450 to your computer and use it in GitHub Desktop.
Save billinghamj/6723450 to your computer and use it in GitHub Desktop.
#import "UIViewController+UniversalModal.h"
@implementation UIViewController (UniversalModal)
- (void)presentViewControllerFromVisibleViewController:(UIViewController *)viewControllerToPresent
animated:(BOOL)animated
completion:(void (^)(void))completion
{
if ([self isKindOfClass:[UINavigationController class]])
{
UINavigationController *navController = (UINavigationController *)self;
[navController.topViewController presentViewControllerFromVisibleViewController:viewControllerToPresent
animated:animated
completion:completion];
}
else if (self.presentedViewController)
[self.presentedViewController
presentViewControllerFromVisibleViewController:viewControllerToPresent
animated:animated
completion:completion];
else
[self presentViewController:viewControllerToPresent
animated:animated
completion:completion];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment