2013-10-09 40 views
2

我看到的遊戲,像 王國衝突 城堡故事iOS版:我的應用程序

能夠到他們的遊戲中推出的AppStore沒有減少他們的遊戲內推出AppStore的頁面。 AppStore頁面將從最下面滑入,顯示一個遊戲頁面,玩家可以下載該遊戲,輸入密碼,關閉頁面,並且它們仍然在遊戲中。

有沒有辦法做到這一點? 我只能最小化自己的應用程序,並打開Appstore。

請指教。 感謝

回答

5

您可以使用SKStoreProductViewController類

進口StoreKit框架

#import <StoreKit/StoreKit.h> 

落實SKStoreProductViewControllerDelegate

@interface MyViewControllerClass : NSObject <SKStoreProductViewControllerDelegate> { 
} 

- (void) openAppStore 
{ 
    if(NSStringFromClass([SKStoreProductViewController class]) != nil) 
    { 
     SKStoreProductViewController *viewCont = [[SKStoreProductViewController alloc] init]; 
     viewCont.delegate = self; 
     [viewCont loadProductWithParameters:[NSDictionary dictionaryWithObject:@"APP_ID_FROM_ITUNES" forKey:SKStoreProductParameterITunesItemIdentifier] completionBlock:nil]; 
     [self.navigationController presentViewController:viewCont animated:YES completion:nil]; 
    } 
    else 
    { 
     // open safari 
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/us/app/facebook/id284882215?mt=8"]]; 
    } 
} 


// SKStoreProductViewControllerDelegate 
-(void)productViewControllerDidFinish:(SKStoreProductViewController *)productViewController 
{ 
    [productViewController dismissViewControllerAnimated:YES completion:nil]; 
} 
+0

嗨,這工作對我罰款。 但我有2個問題, 1)當我點擊AppStore中的取消時,它崩潰。 2)當我用iPad玩iPhone遊戲。在查看器中加載的AppStore,將iPad AppStore解析出來,因此大部分內容都不會被看到。那麼,我是否假設即使遊戲是iPhone遊戲,iPad也將無法加載iPhone Appstore? 請注意, –

+0

崩潰日誌說什麼? 2.你是對的,iPad無法加載iPhone appstore。 – Sohaib

+0

您的更新代碼有效。非常感謝。 –

相關問題