码迷,mamicode.com
首页 > 其他好文 > 详细

SKStoreProductViewController

时间:2016-05-27 18:18:48      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

1、添加库

#import <StoreKit/StoreKit.h>

 2、添加代理

<SKStoreProductViewControllerDelegate>

 3、添加逻辑代码

- (void)evaluate

{
    
    Class isAllow = NSClassFromString(@"SKStoreProductViewController");
    
    if (isAllow != nil && ![[UIDevice currentDevice].model  isEqualToString:@"iPhone Simulator"])
        
    {

        
        __weak __typeof(self) weakself = self;
        
        SKStoreProductViewController *product = [[SKStoreProductViewController alloc] init];
        
        product.delegate = self;
        
        [product loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:@"xxxx"} completionBlock:^(BOOL result, NSError *error) {
            
            __strong __typeof(weakself) strongself = weakself;
            

            if (error) {
                
                NSLog(@"error = %@ with userinfo = %@",error,[error userInfo]);
                
            } else {
                
                [strongself presentViewController:product animated:YES completion:nil];
                
            }
            
        }];
        
    }
    
    else
        
    {
        //http://itunes.apple.com/us/app/id%d
        
        //http://itunes.apple.com/us/app/id
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/us/app/idxxxxx"]];
        
    }
    
}

- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController

{
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
}

 4、SKStoreProductViewController跳转截图

 技术分享

 

5、openURL截图

技术分享

 

SKStoreProductViewController

标签:

原文地址:http://www.cnblogs.com/superbobo/p/5535442.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!