SKStoreProductViewController类是UIViewController的子类, 如果你对view controller比较熟悉的话,那SKStoreProductViewController使用起来也非常简单了。当你希望向用户展示App Store中产品时,你需要:

1.实例化一个SKStoreProductViewController类
2.设置它的delegate
3.把sotre product视图控制器显示给消费者

剩下的就交给操作系统来处理了。需要记住一点的是SKStoreProductViewController只能以模态的方式显示。SKStoreProductViewControllerDelegate协议定义了一个单独的方法—productViewControllerDidFinish:,当消费者离开App Store时会调用这个方法—一般是通过点击左上角画面中的取消按钮。通过给代理发送productViewControllerDidFinish:消息,操作系统就会把控制权返回到你的程序。当然你不能忘了 只支持IOS6.0及其以上~~

步骤:

1.添加 storeKit.framework

2.头文件里 加上

#import <StoreKit/StoreKit.h>

@interface ViewController : UIViewController<SKStoreProductViewControllerDelegate>

3.直接在m中实现

- (IBAction)doAction:(UIButton *)sender {
      [self showAppInApp:@"xxxxxx"];//此处xxxxx需要替换为需要的appID
}
- (void)showAppInApp:(NSString *)_appId {
  Class isAllow = NSClassFromString(@"SKStoreProductViewController");
  if (isAllow != nil) {
    SKStoreProductViewController *sKStoreProductViewController = [[SKStoreProductViewController alloc] init];
    sKStoreProductViewController.delegate = self;
    [sKStoreProductViewController loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier: _appId}
                      completionBlock:^(BOOL result, NSError *error) {
                        if (result) {
                          [self presentViewController:_SKSVC
                                             animated:YES
                                           completion:nil];
                        }
                        else{
                          NSLog(@"%@",error);
                        }
                      }];
  }
  else{
    //低于iOS6没有这个类
    NSString *string = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/us/app/id%@?mt=8",_appId];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:string]];
  }
}

#pragma mark - SKStoreProductViewControllerDelegate

//对视图消失的处理
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {

[viewController dismissViewControllerAnimated:YES
                                     completion:nil];

}

iOS 应用内跳转到appstore里下载的更多相关文章

  1. ios应用内跳转到appstore里评分

    NSString *str = [NSString stringWithFormat:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore ...

  2. iOS应用内跳转到指定系统设置页

    APP的跳转: 通过[ [UIApplication sharedApplication] openURL:url]这种方法来实现的. iOS 10以后跳转设置页要用 [[UIApplication ...

  3. 关于在iOS应用中跳转到AppStore

    1.获取app 在AppStore上的网址 eg: NSString * appURLStr = @"https://itunes.apple.com/cn/app/shi-ke-zu-qi ...

  4. h5 js判断是安卓还是ios设备,跳转到对应的下载地址

    /*ios和安卓跳转 js*/$(function(){ var u = navigator.userAgent; var ua = navigator.userAgent.toLowerCase() ...

  5. iOS应用内跳转系统设置相关界面的方法

    在iOS开发中,有时会有跳转系统设置界面的需求,例如提示用户打开蓝牙或者WIFI,提醒用户打开推送或者位置权限等.在iOS6之后,第三方应用需要跳转系统设置界面,需要在URL type中添加一个pre ...

  6. iOS 应用内跳转到系统设置

    在iOS5下面版本号使用下面方法:[IOS5.1+之后不能使用此方法.iOS8的跳转方法已找到见下方,iOS7的正在摸索,欢迎大家给出观点意见] 通过URL Scheme的方式打开内置的Setting ...

  7. iOS应用内跳转百度高德苹果地图

    移动开发经常用到基于位置的一些导航功能,但是对于对导航功能依赖性不强的的应用,我们直接采用应用外跳转地图APP即可. 但是应用间跳转,首先需要设置白名单, 在iOS 9 下涉及到平台客户端跳转,系统会 ...

  8. iOS APP版本更新跳转到App Store下载/更新方法

    使用下面的连接即可跳转到App Store itms-apps://itunes.apple.com/cn/app/id***********                  其中********* ...

  9. iOS开发中,应用内直接跳转到Appstore

    iOS开发中,应用内直接跳转到Appstore 1.进入appstore中指定的应用NSString *str = [NSString stringWithFormat:                ...

随机推荐

  1. Mysql 学习

    一.ubuntu下mysql的安装: 通过sudo apt-get install mysql-server 完成: 然后可以通过/etc/init.d/mysql 进行start/stop/rest ...

  2. Hashtable和Dictionary<T,K>的使用

    由于Hashtable内部自带有排序(根据Key的HashCode来进行的),因此有时在使用Hashtable时就会造成数据顺序不可控的情况,有两种办法可以解决, 测试代码: Dictionary&l ...

  3. linux下C语言获取微秒级时间

    使用C语言在linux环境下获得微秒级时间 1.数据结构 int gettimeofday(struct timeval*tv, struct timezone *tz); 其参数tv是保存获取时间结 ...

  4. RowDataBound事件

    RowDataBound事件在创建gridView控件时,必须先为GridView的每一行创建一个GridViewRow对象,创建每一行时,将引发一个RowCreated事件:当行创建完毕,每一行Gr ...

  5. easyui datagrid 增删改查示例

    查询JSP页面 <!doctype html> <%@include file="/internet/common.jsp"%> <!-- 新样式右侧 ...

  6. MySQL的show语句大全

    常用的MySQL show 语句列举如下: 1.show databases ; // 显示mysql中所有数据库的名称 2.show tables [from database_name]; // ...

  7. SQL判断语句用法和多表查询

    1.格式化时间sql语句 本例中本人随便做了两张表,和实际不是很相符,只是想说明sql语句的写法. 例1表格式如下: 需求:查询出本表,但需要使time字段的时间格式为yyyy-MM-dd,比如:20 ...

  8. POJ 3628 Bookshelf 2(01背包)

    Bookshelf 2 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9488   Accepted: 4311 Descr ...

  9. fastjson生成json时Null属性不显示

    举个例子 生成JSON代码片段 Map < String , Object > jsonMap = new HashMap< String , Object>(); jsonM ...

  10. MongoDB命令模式下的条件过滤总结

    db.tb1.find() //查询全部,用it查看下一页.db.tb1.find({"age":1}) //查询年龄==1的记录db.tb1.find({},{"age ...