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. ARC指南2 - ARC的开启和禁止

    要想将非ARC的代码转换为ARC的代码,大概有2种方式: 1.使用Xcode的自动转换工具 2.手动设置某些文件支持ARC 一.Xcode的自动转换工具 Xcode带了一个自动转换工具,可以将旧的源代 ...

  2. Oracle用户信息查询

    1.查看所有用户: select * from dba_users;    select * from all_users;    select * from user_users; 2.查看用户或角 ...

  3. hdu 3348 coins

    这道题算是一道很经典的题,很好的诠释了贪心和动态规划的不同功能.求最少钱的数量用贪心就够了,但是求最多钱的数量要用到动态规划的思想,每步都尽量保留最大 数量.具体看程序注解: #include&quo ...

  4. Servlet 编程 简单流程处理(重定向)

    流程(来自jiekexueyuan) servlet sucess.jsp error.asp同理 运行结果:

  5. 【转】SQLServer内部原理

    原文地址:http://twb.iteye.com/blog/182083 在讲SQLSERVER内部原理的之前,我觉得非常有必要向大家介绍一下SQLSERVER的历史. 让我们站在1999年,看看计 ...

  6. spring aop中的propagation的7种配置的意思

    1.前言. 在声明式的事务处理中,要配置一个切面,即一组方法,如 <tx:advice id="txAdvice" transaction-manager="txM ...

  7. 【Spec for GS5】不要嘲笑程序员不懂烂漫

    // // main.cpp // 生日快乐 // // Created by wasdns on 16/11/21. // Copyright © 2016年 wasdns. All rights ...

  8. Javascript 笔记与总结(1-4)this

    js 中函数的 4 种调用方式: ① 作为普通函数来调用,this 的值指向 window,准确地说,this 为 null,被解释成为 window.在 ECMAScript5 标准中,如果 thi ...

  9. MySQL解压版安装配置

    官网下载地址:http://dev.mysql.com/downloads/windows/installer/ (可以选择解压版zip下载,也可以选择msi安装版.) 解压zip版配置: 1. 下载 ...

  10. Sublime Text3 中文汉化

    首先安装Package Control,如果已经安装过可以跳过此步骤.可以按照官网这里https://packagecontrol.io/installation 复制命令或者直接复制下面: impo ...