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 {
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;
if ([self respondsToSelector:presentingViewControllerSelector]) {
presentingViewController = [self performSelector:presentingViewControllerSelector];
}
else {
presentingViewController = [self parentViewController];
}
BW_IF_IOS5_OR_GREATER(presentingViewController = self.navigationController.presentingViewController;);
BW_IF_PRE_IOS5(presentingViewController = self.navigationController.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_];
}