Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed an issue with modal controller on iOS6+ #104

Merged
merged 1 commit into from

2 participants

@olarivain

Hey folks,

This pull request fixes an issue when the SK controller is attempted to be presented on the root view controller, while the root view controller is modally presenting another controller.
The current implementation fails to present the SK since the root view controller already has a modally presented controller.

The fix is fairly simple: iterate through "presentedViewController" when fetching the root view controller, and the same when dismissing it.

@olarivain olarivain fixed issue causing the StoreKit view controller to not be properly p…
…resented when the root view controller is presenting modally
3c7b7bb
@arashpayan arashpayan merged commit 17f260f into arashpayan:master
@arashpayan
Owner

Thank you. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 12, 2013
  1. @olarivain

    fixed issue causing the StoreKit view controller to not be properly p…

    olarivain authored
    …resented when the root view controller is presenting modally
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 2 deletions.
  1. +21 −2 Appirater.m
View
23 Appirater.m
@@ -391,13 +391,28 @@ + (id)getRootViewController {
{
UIResponder *responder = [subView nextResponder];
if([responder isKindOfClass:[UIViewController class]]) {
- return responder;
+ return [self topMostViewController: (UIViewController *) responder];
}
}
return nil;
}
++ (UIViewController *) topMostViewController: (UIViewController *) controller {
+ BOOL isPresenting = NO;
+ do {
+ // this path is called only on iOS 6+, so -presentedViewController is fine here.
+ UIViewController *presented = [controller presentedViewController];
+ isPresenting = presented != nil;
+ if(presented != nil) {
+ controller = presented;
+ }
+
+ } while (isPresenting);
+
+ return controller;
+}
+
+ (void)rateApp {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
@@ -480,7 +495,11 @@ + (void)closeModal {
[[UIApplication sharedApplication]setStatusBarStyle:_statusBarStyle animated:_usesAnimation];
BOOL usedAnimation = _usesAnimation;
[self setModalOpen:NO];
- [[UIApplication sharedApplication].keyWindow.rootViewController dismissViewControllerAnimated:_usesAnimation completion:^{
+
+ // get the top most controller (= the StoreKit Controller) and dismiss it
+ UIViewController *presentingController = [UIApplication sharedApplication].keyWindow.rootViewController;
+ presentingController = [self topMostViewController: presentingController];
+ [presentingController dismissViewControllerAnimated:_usesAnimation completion:^{
if ([self.sharedInstance.delegate respondsToSelector:@selector(appiraterDidDismissModalView:animated:)]) {
[self.sharedInstance.delegate appiraterDidDismissModalView:(Appirater *)self animated:usedAnimation];
}
Something went wrong with that request. Please try again.