From 6cd15491362e4107cb9e1fec8abab4c30a6bb3b6 Mon Sep 17 00:00:00 2001 From: Thomas Dohmke Date: Sat, 3 Dec 2011 18:35:05 +0100 Subject: [PATCH] Merged changed from https://github.com/mackross/HockeyKit/commit/80cd88e97656b54e1e0cf3d18b5a4c6c28b0af5d (thanks to https://github.com/mackross). --- Classes/BWHockeyViewController.m | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Classes/BWHockeyViewController.m b/Classes/BWHockeyViewController.m index 8ac38d7132..990503fd9b 100644 --- a/Classes/BWHockeyViewController.m +++ b/Classes/BWHockeyViewController.m @@ -268,21 +268,27 @@ - (void)onAction:(id)sender { if (self.modal) { - // Note that as of 5.0, parentViewController will no longer return the presenting view controller + SEL presentingViewControllerSelector = NSSelectorFromString(@"presentingViewController"); UIViewController *presentingViewController = nil; - - BW_IF_IOS5_OR_GREATER(presentingViewController = self.navigationController.presentingViewController;); - BW_IF_PRE_IOS5(presentingViewController = self.navigationController.parentViewController;) - + if ([self respondsToSelector:presentingViewControllerSelector]) { + presentingViewController = [self performSelector:presentingViewControllerSelector]; + } + else { + presentingViewController = [self parentViewController]; + } + + // If there is no presenting view controller just remove view if (presentingViewController) { - [self.navigationController dismissModalViewControllerAnimated:YES]; - } else { + [presentingViewController dismissModalViewControllerAnimated:YES]; + } + else { [self.navigationController.view removeFromSuperview]; } } - else + else { [self.navigationController popViewControllerAnimated:YES]; + } [[UIApplication sharedApplication] setStatusBarStyle:statusBarStyle_]; }