目前是有两种方法实现跳转:一种是直接通过openURL:的方法跳转进入,另一种是通过苹果自身的SKStoreProductViewController 该控制器去实现,
他们之前的区别是,前者直接跳转到appStore,后者则在应用内打开
第一种:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/cn/app/shan-shan-pen-di-fu-nu-jian/appid?mt=8"]];
第二种:需要添加StoreKit.framework系统库 #<StoreKit/StoreKit.h>, 实现SKStoreProductViewControllerDelegate代理
//初始化一个VC
SKStoreProductViewController *storeProductViewContorller = [[SKStoreProductViewControlleralloc] init];
storeProductViewContorller.delegate = self;
//加载一个新的视图展示
[storeProductViewContorller loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @"appid"} completionBlock:^(BOOL result, NSError *error) { //block回调
if(error){
NSLog(@"error %@ with userInfo %@",error,[error userInfo]);
}else{
//弹出appstore
[self presentViewController:storeProductViewContorller animated:YES completion:nil ];
} }]
//取消按钮监听
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController{
[self dismissViewControllerAnimated:YES completion:nil];
}