简体   繁体   中英

SKStoreProductViewController crashes on iphone iOS 7 landscape app

I have a universal landscape mode app. SKStoreProductViewController works fine on iPad. But crashes on iphone ios 7. Even I set the SKStoreProductViewController to display on portrait on iPhone.

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
   if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
       NSLog(@"iphone portrait");
       return UIInterfaceOrientationPortrait;
   }
   else
       return [super preferredInterfaceOrientationForPresentation];
}

The SKStoreProductViewController shows on portrait on iphone iOS 7, but when I rotate the phone, it crashes. I got error message says:

* Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'

Anyone knows how to solve the issue?
Thanks

You want should autorotate to return NO if the application and the ViewController have no common interface orientations. Here's my solution:

Subclass SKStoreProductViewController and override -shouldAutorotate with the following:

- (BOOL)shouldAutorotate {
    UIInterfaceOrientationMask applicationSupportedOrientations = [[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:[[UIApplication sharedApplication] keyWindow]];
    UIInterfaceOrientationMask viewControllerSupportedOrientations = [self supportedInterfaceOrientations];
    return viewControllerSupportedOrientations & applicationSupportedOrientations;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM