Permalink
Browse files

fix StoreKit view, need to determine correct rootViewController

  • Loading branch information...
1 parent 588ca15 commit 986f3bbc4e404957a8f25c8bfc8e10f8ccb1761d mrcmd committed Jan 12, 2013
Showing with 15 additions and 1 deletion.
  1. +15 −1 Appirater.m
View
@@ -372,6 +372,20 @@ + (void)userDidSignificantEvent:(BOOL)canPromptForRating {
});
}
++ (id)getRootViewController {
+ UIWindow *window = [[UIApplication sharedApplication] keyWindow];
+ if (window.windowLevel != UIWindowLevelNormal) {
+ NSArray *windows = [[UIApplication sharedApplication] windows];
+ for(window in windows) {
+ if (window.windowLevel == UIWindowLevelNormal) {
+ break;
+ }
+ }
+ }
+
+ return [[[window subviews] objectAtIndex:0] nextResponder];
+}
+
+ (void)rateApp {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
@@ -386,7 +400,7 @@ + (void)rateApp {
[storeViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:appId} completionBlock:nil];
storeViewController.delegate = self.sharedInstance;
[self.sharedInstance.delegate appiraterWillPresentModalView:self.sharedInstance animated:_usesAnimation];
- [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:storeViewController animated:_usesAnimation completion:^{
+ [[self getRootViewController] presentViewController:storeViewController animated:_usesAnimation completion:^{
[self setModalOpen:YES];
//Temporarily use a black status bar to match the StoreKit view.
[self setStatusBarStyle:[UIApplication sharedApplication].statusBarStyle];

0 comments on commit 986f3bb

Please sign in to comment.