Skip to content

Instantly share code, notes, and snippets.

@pablocarrillo
Forked from MartinMoizard/gist:6537467
Last active August 29, 2015 14:04
Show Gist options
  • Save pablocarrillo/defc7a1c70472b3d8742 to your computer and use it in GitHub Desktop.
Save pablocarrillo/defc7a1c70472b3d8742 to your computer and use it in GitHub Desktop.
Present a modal view controller always
- (void)presentViewControllerFromVisibleViewController:(UIViewController *)viewControllerToPresent
{
if ([self isKindOfClass:[UINavigationController class]]) {
UINavigationController *navController = (UINavigationController *)self;
[navController.topViewController presentViewControllerFromVisibleViewController:viewControllerToPresent];
} else if (self.presentedViewController) {
[self.presentedViewController presentViewControllerFromVisibleViewController:viewControllerToPresent];
} else {
[self presentModalViewController:viewControllerToPresent animated:YES];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment