首页 文章

SKStoreProductViewController在iphone iOS 7横向应用程序上崩溃

提问于
浏览
4

我有一个通用的横向模式应用程序 . SKStoreProductViewController在iPad上运行良好 . 但在iphone ios上崩溃7.甚至我将SKStoreProductViewController设置为在iPhone上的肖像上显示 .

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

SKStoreProductViewController在iOS 7的iphone上显示,但是当我旋转手机时,它会崩溃 . 我收到错误消息说:

*由于未捕获的异常终止应用'UIApplicationInvalidInterfaceOrientation',原因:'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'

谁知道如何解决这个问题?
谢谢

1 回答

  • 8

    如果应用程序和ViewController没有通用的接口方向,您希望自动旋转返回NO . 这是我的解决方案:

    子类SKStoreProductViewController并使用以下内容覆盖-shouldAutorotate:

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

相关问题