Skip to content

Instantly share code, notes, and snippets.

@aquarius
Created August 22, 2011 11:02
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 aquarius/1162145 to your computer and use it in GitHub Desktop.
Save aquarius/1162145 to your computer and use it in GitHub Desktop.
Hide and present new modal view animated
@implementation UIViewController (Convenience)
- (void)mn_hideCurrentModalControllerAndPresentController:(UIViewController *)controller
{
if (self.modalViewController) {
[self dismissModalViewControllerAnimated:YES];
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self presentModalViewController:controller animated:YES];
});
} else {
[self presentModalViewController:controller animated:YES];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment