你好,游客 登录 注册 搜索
背景:
阅读新闻

iOS6.0 新功能:在应用程序内展示App Store

[日期:2013-04-29] 来源:Linux社区  作者:pearlhuzhu [字体:大 中 小]

1、新建工程,导入库文件:StoreKit.framework,并且导入头文件,如下:

#import <StoreKit/StoreKit.h>

2、在需要点击事件中,添加代码,如下:

- (IBAction)gotoStore:(id)sender {
    // Initialize Product View Controller
    SKStoreProductViewController *storeProductViewController = [[SKStoreProductViewController alloc] init];
    // Configure View Controller
    [storeProductViewController setDelegate:self];
   
    [storeProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @"594467299"}
                                          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];       
                                              }   
                                          }];
}

3、设置协议 SKStoreProductViewControllerDelegate,并且实习协议中的方法,如下:

- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0)
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

4、在真机上测试,即可实现效果。

linux
相关资讯       iOS6.0 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款