Merged changed from 80cd88e976 (thanks to https://github.com/mackross).

This commit is contained in:
Thomas Dohmke 2011-12-03 18:35:05 +01:00
parent b1a4f22c2b
commit 6cd1549136

View File

@ -268,21 +268,27 @@
- (void)onAction:(id)sender { - (void)onAction:(id)sender {
if (self.modal) { if (self.modal) {
// Note that as of 5.0, parentViewController will no longer return the presenting view controller // Note that as of 5.0, parentViewController will no longer return the presenting view controller
SEL presentingViewControllerSelector = NSSelectorFromString(@"presentingViewController");
UIViewController *presentingViewController = nil; UIViewController *presentingViewController = nil;
if ([self respondsToSelector:presentingViewControllerSelector]) {
BW_IF_IOS5_OR_GREATER(presentingViewController = self.navigationController.presentingViewController;); presentingViewController = [self performSelector:presentingViewControllerSelector];
BW_IF_PRE_IOS5(presentingViewController = self.navigationController.parentViewController;) }
else {
presentingViewController = [self parentViewController];
}
// If there is no presenting view controller just remove view
if (presentingViewController) { if (presentingViewController) {
[self.navigationController dismissModalViewControllerAnimated:YES]; [presentingViewController dismissModalViewControllerAnimated:YES];
} else { }
else {
[self.navigationController.view removeFromSuperview]; [self.navigationController.view removeFromSuperview];
} }
} }
else else {
[self.navigationController popViewControllerAnimated:YES]; [self.navigationController popViewControllerAnimated:YES];
}
[[UIApplication sharedApplication] setStatusBarStyle:statusBarStyle_]; [[UIApplication sharedApplication] setStatusBarStyle:statusBarStyle_];
} }