Skip to content
This repository
Browse code

fix StoreKit view, need to determine correct rootViewController

  • Loading branch information...
commit 986f3bbc4e404957a8f25c8bfc8e10f8ccb1761d 1 parent 588ca15
authored January 12, 2013

Showing 1 changed file with 15 additions and 1 deletion. Show diff stats Hide diff stats

  1. 16  Appirater.m
16  Appirater.m
@@ -372,6 +372,20 @@ + (void)userDidSignificantEvent:(BOOL)canPromptForRating {
372 372
                    });
373 373
 }
374 374
 
  375
++ (id)getRootViewController {
  376
+    UIWindow *window = [[UIApplication sharedApplication] keyWindow];
  377
+    if (window.windowLevel != UIWindowLevelNormal) {
  378
+        NSArray *windows = [[UIApplication sharedApplication] windows];
  379
+        for(window in windows) {
  380
+            if (window.windowLevel == UIWindowLevelNormal) {
  381
+                break;
  382
+            }
  383
+        }
  384
+    }
  385
+    
  386
+    return [[[window subviews] objectAtIndex:0] nextResponder];
  387
+}
  388
+
375 389
 + (void)rateApp {
376 390
 	
377 391
 	NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
@@ -386,7 +400,7 @@ + (void)rateApp {
386 400
 		[storeViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:appId} completionBlock:nil];
387 401
 		storeViewController.delegate = self.sharedInstance;
388 402
 		[self.sharedInstance.delegate appiraterWillPresentModalView:self.sharedInstance animated:_usesAnimation];
389  
-		[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:storeViewController animated:_usesAnimation completion:^{
  403
+		[[self getRootViewController] presentViewController:storeViewController animated:_usesAnimation completion:^{
390 404
 			[self setModalOpen:YES];
391 405
 			//Temporarily use a black status bar to match the StoreKit view.
392 406
 			[self setStatusBarStyle:[UIApplication sharedApplication].statusBarStyle];

0 notes on commit 986f3bb

Please sign in to comment.
Something went wrong with that request. Please try again.