微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我有一个通用的横向模式应用程序. 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’终止应用程序,原因:’支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES’

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

解决方法

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

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐