-(void)dismissToRootViewController { UIViewController *vc = self; while (vc.presentingViewController) { vc = vc.presentingViewController; } [vc dismissViewControllerAnimated:YES completion:nil]; }