我有一个通用的横向模式应用程序. 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; }