4

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

Emmy
  • 3,949
  • 5
  • 28
  • 30
  • 1
    Did you have a look @ http://stackoverflow.com/questions/12540597/supported-orientations-has-no-common-orientation-with-the-application-and-shoul ? – Daniel Nov 01 '13 at 21:56

1 Answers1

10

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;
}
Jerceratops
  • 389
  • 4
  • 12
  • SKStoreProductViewController don't work correctly in iOS 11 / iOS 12 on landscape mode with support orientations :O – sarra.srairi Sep 20 '18 at 10:56