2012-10-13 45 views
10

我正在實施StoreKit應用內購買界面,儘管看起來SKStoreProductViewController在iPad上處理風景,但它似乎沒有爲iPhone上的我的應用程序這樣做(它是普遍的)。SKStoreProductViewController和GKHostedAuthenticateViewController沒有iPhone風景模式

SKStoreProductViewController的界面非常有限,我似乎無法以任何方式操作VC有沒有其他人遇到過這個問題?任何解決方法?

當我運行iPad上的代碼時,SKStoreProductViewController從左側進來,大約一英寸,然後掛在那裏直到被解散。它看起來很實用,但是它解僱了在解僱時彈出它的VC。

下面的代碼:

// Set up the store vc (creating it if not already done) 
if (self.storeVC == nil) self.storeVC = [[SKStoreProductViewController alloc] init]; 
self.storeVC.delegate = self; 
NSDictionary *params = [NSDictionary dictionaryWithObject:appID forKey:SKStoreProductParameterITunesItemIdentifier]; 

// Set up a HUD in case connecting to the store takes a while 
[MBProgressHUD showHUDAddedTo:self.view animated:YES]; 

[self.storeVC loadProductWithParameters:params 
         completionBlock:^(BOOL result, NSError *error) { 
     [MBProgressHUD hideHUDForView:self.view animated:YES]; 
     if (result) { 
      [self presentViewController:self.storeVC animated:NO completion:^{ 
      }]; 
     } 
    }]; 

更妙的是,我們遇到的GKHostedAuthenticateViewController這是視圖 - 控制從方法返回了同樣的問題:

GKLocalPlayer.authenticateHandler = ^(UIViewController *loginVC, NSError *error) {}; 

重申一下:這兩個在iPhones(但不是iPad)上處於肖像模式,並強制UI進入肖像模式。返回後,您的應用的用戶界面會混亂。

+1

我剛纔遇到類似的問題。我只在橫向模式下製作iPhone應用程序。創建「SKStoreProductViewController」來查看商店中的另一個iOS應用程序 - 「SKStoreProductViewController」看起來不太好 - 有三個選項卡用於選擇以下滾動視圖的內容。滾動視圖不使用完整的橫向寬度,這使得它看起來......「半分」,我不認爲有任何其他詞。 – Jonny

+1

@Jonny更重要的是,在最新的ios 7上,skstoreproductviewcontroller實際上在橫向模式下崩潰 – OMGPOP

回答

5

我遇到了類似的問題。我的通用應用程序處於風景中,但SKStoreProductViewController在iPad上的橫向效果非常好,但它在iPhone上呈現出視覺干擾。

我的解決方案是強制iPhone以縱向方式呈現SKStoreProductViewController。它與應用程序的其他部分沒有相同的方向,但有點令人傷心,但它比屏幕的一半切斷要好。

我做到了這一點,通過使用下面的自定義子類:

@interface SKPortraitStoreProductViewController : SKStoreProductViewController 
@end 

@implementation SKPortraitStoreProductViewController 
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { 
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) 
     return UIInterfaceOrientationPortrait; 
    else 
     return [super preferredInterfaceOrientationForPresentation]; 
} 
@end
+0

但iphone iphone 7上的應用程序崩潰。我正在尋找解決方案。 – Emmy

+0

我也是。任何人都可以在iOS 7上使用風景應用程序中的SKStoreProductViewController? – Mayoneez

0

嘗試呈現之前改變你的SKStoreProductViewControllermodalPresentationStyle財產。

我已經有好運了,將其設置爲UIModalPresentationPageSheet,這似乎很好地覆蓋了iPad的風景。