我有一个通用横向模式应用程序。 SKStoreProductViewController 在 iPad 上工作正常。但在 iphone ios 7 上崩溃。甚至我将 SKStoreProductViewController 设置为在 iPhone 上以纵向显示。
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
NSLog(@"iphone portrait");
return UIInterfaceOrientationPortrait;
}
else
return [super preferredInterfaceOrientationForPresentation];
}
SKStoreProductViewController 在 iphone iOS 7 上以纵向显示,但当我旋转手机时,它崩溃了。我收到错误消息说:
* 由于未捕获的异常“UIApplicationInvalidInterfaceOrientation”而终止应用程序,原因:“支持的方向与应用程序没有共同的方向,shouldAutorotate 返回 YES”
有人知道如何解决这个问题吗?
谢谢
最佳答案
如果应用程序和 ViewController 没有共同的界面方向,您希望应该自动旋转以返回 NO。这是我的解决方案:
子类 SKStoreProductViewController 并使用以下内容覆盖 -shouldAutorotate:
- (BOOL)shouldAutorotate {
UIInterfaceOrientationMask applicationSupportedOrientations = [[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:[[UIApplication sharedApplication] keyWindow]];
UIInterfaceOrientationMask viewControllerSupportedOrientations = [self supportedInterfaceOrientations];
return viewControllerSupportedOrientations & applicationSupportedOrientations;
}
关于iphone - SKStoreProductViewController 在 iphone iOS 7 横向应用程序上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19734943/