首页 > 其他 > 详细

SKStoreProductViewController

时间:2016-05-27 18:18:37      阅读:206      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!