Skip to content

Instantly share code, notes, and snippets.

@Clafou
Forked from MartinMoizard/gist:6537467
Last active December 24, 2015 02:09
Show Gist options
  • Select an option

  • Save Clafou/6728543 to your computer and use it in GitHub Desktop.

Select an option

Save Clafou/6728543 to your computer and use it in GitHub Desktop.
Edited the original Gist to remove the call to presentModalViewController:animated:, which simplifies it and removes its parameter. This method has the sole aim of finding the adequate UIViewController. It's up to this method's caller to send presentModalViewController:animated:
- (UIViewController *)modalPresenter
{
if ([self isKindOfClass:[UINavigationController class]]) {
return [((UINavigationController *)self).topViewController modalPresenter];
} else if (self.presentedViewController) {
return [self.presentedViewController modalPresenter];
} else {
return self;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment