2013-11-01 68 views
4

我有一个通用的横向模式的应用程序。 SKStoreProductViewController在iPad上正常工作。但iPhone ios 7崩溃。即使我将SKStoreProductViewController设置为在iPhone上以纵向显示。SKStoreProductViewController在iPhone上崩溃iOS 7的景观应用程序

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

SKStoreProductViewController在iPhone iOS 7上的肖像上显示,但是当我旋转手机时,它崩溃了。我收到错误消息称:

*终止应用程序由于未捕获的异常“UIApplicationInvalidInterfaceOrientation”,理由是:“支持的方向与应用程序中没有共同的方向,并shouldAutorotate将返回YES”

任何人知道如何解决问题?
谢谢

+1

你看看@ http://stackoverflow.com/questions/12540597/supported-orientations-has-no-共同的方向与应用程序和肩膀? – Daniel

回答

7

如果应用程序和ViewController没有公共的接口方向,您应该自动旋转以返回NO。这里是我的解决方案:

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

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

B R I L L I A N N T!谢谢 – SpaceDog