App跳转到APPStore

0.168字数 139阅读 106

http://www.jianshu.com/p/25fb79fb2e5f


if (btn.tag == 1) {        

//第一种方法  直接跳转       

 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://itunes.apple.com/app/id1018221712"]];    }else{       

 //第二中方法  应用内跳转       

//1:导入StoreKit.framework,控制器里面添加框架#import//2:实现代理SKStoreProductViewController *storeProductViewContorller = [[SKStoreProductViewController alloc] init];

storeProductViewContorller.delegate = self;

//        ViewController *viewc = [[ViewController alloc]init];

//        __weak typeof(viewc) weakViewController = viewc;

//加载一个新的视图展示

[storeProductViewContorller loadProductWithParameters:

//appId

@{SKStoreProductParameterITunesItemIdentifier : @"1018221712"} completionBlock:^(BOOL result, NSError *error) {

//回调

if(error){

NSLog(@"错误%@",error);

}else{

//AS应用界面

[self presentViewController:storeProductViewContorller animated:YES completion:nil];

}

}];

}

推荐阅读更多精彩内容