import “ViewController.h”
import StoreKit/StoreKit.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//第一种方法 直接跳转
UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(100, 100, 100, 50)];
btn.backgroundColor = [UIColor redColor];
[btn setTitle:@”直接跳转” forState:UIControlStateNormal];
btn.tag = 1;
[btn addTarget:self action:@selector(btn:) forControlEvents:UIControlEventTouchUpInside];
//第二中方法 应用内跳转
UIButton *btnT = [[UIButton alloc]initWithFrame:CGRectMake(100, 300, 100, 50)];
btnT.backgroundColor = [UIColor purpleColor];
btnT.tag = 2;
[btnT setTitle:@”应用内跳转” forState:UIControlStateNormal];
[btnT addTarget:self action:@selector(btn:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
[self.view addSubview:btnT];
} (void)btn:(UIButton *)btn{
if (btn.tag == 1) {
//第一种方法 直接跳转
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@”itms-apps://itunes.apple.com/app/id1090805247”]];
}else{
//第二中方法 应用内跳转
//1:导入StoreKit.framework,控制器里面添加框架#import
pragma mark - 评分取消按钮监听
//取消按钮监听
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController{
[self dismissViewControllerAnimated:YES completion:nil];
}