簡體   English   中英

SKStoreProductViewController在iphone iOS 7橫向應用程序上崩潰

[英]SKStoreProductViewController crashes on iphone iOS 7 landscape app

我有一個通用的橫向模式應用程序。 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;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM