IOS6.0 应用内直接下载程序 不需跳转AppStore
来源:互联网 发布:有首单立减的外卖软件 编辑:程序博客网 时间:2024/05/17 01:22
闲来没事看了篇文章 应用内创建应用商店环境,不跳转AppStore. 先武断的想一句:放屁。然后好奇的进去看看,原来是IOS6.0的新特性,顿感惭愧。研究下
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];
}
- IOS6.0 应用内直接下载程序 不需跳转AppStore
- IOS6.0 应用内直接下载程序 不需跳转AppStore
- IOS6.0 应用内直接下载程序 不需跳转AppStore
- IOS6.0 应用内直接下载程序 不需跳转AppStore
- IOS6.0 应用内直接下载程序 不需跳转AppStore
- IOS6.0 应用内直接下载程序 不需跳转AppStore
- IOS6 应用内跳转到appstore里下载
- IOS6 应用内跳转到appstore里下载
- 应用内直接跳转AppStore方式
- iOS开发中,应用内直接跳转到Appstore
- iOS开发中,应用内直接跳转到Appstore
- iOS开发中,应用内直接跳转到Appstore
- iOS开发中,应用内直接跳转到Appstore评分
- iOS开发中,应用内直接跳转到Appstore
- iOS开发中,应用内直接跳转到Appstore
- iOS开发,应用内直接跳转到Appstore评分
- 程序内下载App,不用跳转到AppStore
- 程序内下载App,不用跳转到AppStore
- 【验证码】servlet 生成 验证码图片
- HDU 4193
- 杨氏矩阵的查找(二维数组中的查找——剑指offer3)
- 简单工厂模式,工厂方法模式和抽象工厂模式的异同
- 文献综述注意事项
- IOS6.0 应用内直接下载程序 不需跳转AppStore
- 第五周作业——有向图表示及反向图构造
- SSH,不支持从 date 到 BINARY 的转换
- Ubuntu10.10时间/时区设置
- Mysql error 1452 - Cannot add or update a child row: a foreign key constraint fails
- C语言允许数组下标是负数
- poj_1328 贪心
- 计数排序
- 存储过程的一些东西