在應用內展示App Store

來源:互聯網
上載者:User

標籤:ios   app store   storekit   評分   

iOS6 SDK就已經增加了StoreKit工具包,“StoreKit” 顧名思義就是 “商店工具包”的意思,那麼它主要是蘋果公司為了方便開發人員對App Store操作而開發的。比如對app進行評論,我們平時都是直接跳到App Store,那麼現在我們就可以直接在應用內以模態視圖的形式彈出App Store,這樣是不是就更方便?

要使用StoreKit工具包中的功能:

1、首先得匯入StoreKit.framework這個架構,(步驟:target  --->  Build Phase  --->  Link Binary With Libraries  --->  選擇左下角的+號  --->  在彈出框中輸入StoreKit,然後選中添加就好了)

2、然後就是在需要展示App Store中匯入#import <StoreKit/StoreKit.h>標頭檔



以上這兩步準備工作做好後,你就可以使用它的功能了

步驟:

1.執行個體化一個SKStoreProductViewController類

2.設定它的delegate

3.把sotre product視圖控制器顯示給使用者

代碼如下

-(void)openAppStore{    SKStoreProductViewController *storeProductViewController = [[SKStoreProductViewController alloc] init];    [storeProductViewController setDelegate:self];    [storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @"你開發的應用的AppID"}                                          completionBlock:^(BOOL result, NSError *error) {                                              if (error) {                                                  NSLog(@"Error %@ with User Info %@.", error, [error userInfo]);                                              } else {                                                  // Present Store Product View Controller                                                  [self presentViewController:storeProductViewController animated:YES completion:nil];//只能以模態的形式彈出                                              }                                          }];}//當使用者想退出App Store時,點擊模態視圖左上方的取消按鈕會調用此方法-(void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController{    [viewController dismissViewControllerAnimated:YES completion:nil];}



在應用內展示App Store

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.