SKStoreProductViewController的使用,我们想看app的信息或者下载,又不想跳转appstore的方法

Posted hualuoshuijia

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SKStoreProductViewController的使用,我们想看app的信息或者下载,又不想跳转appstore的方法相关的知识,希望对你有一定的参考价值。

代码:

#import <StoreKit/StoreKit.h>
@interface CustomVC ()<SKStoreProductViewControllerDelegate>

    SKStoreProductViewController *_storeVC ;

@end

@implementation CustomVC

- (void)viewDidLoad 
    [super viewDidLoad];
    

#pragma mark SKStoreProductViewControllerDelegate
/**storeVC消失的时候调用的方法*/
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController __TVOS_PROHIBITED NS_AVAILABLE_ios(6_0)
     NSLog(@"---------------------------------------");
    [_storeVC dismissViewControllerAnimated:YES completion:nil];


    
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
    
    _storeVC = [SKStoreProductViewController new];
    _storeVC.delegate = self;
    //    storeVC.view.frame = self.view.frame;
    //    [self.view addSubview:storeVC.view];
    
    if (@available(iOS 11.0, *)) 
        NSDictionary *parame = @SKStoreProductParameterITunesItemIdentifier:@"1467094391";
        
        
        [_storeVC loadProductWithParameters:parame completionBlock:^(BOOL result, NSError * _Nullable error) 
            //加载成功
            NSLog(@"---------------------------------------%d:%@",result,error);
        ];
     else 
        // Fallback on earlier versions
    
    
    [self.navigationController presentViewController:_storeVC animated:YES completion:nil];

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.

*/

@end

 

以上是关于SKStoreProductViewController的使用,我们想看app的信息或者下载,又不想跳转appstore的方法的主要内容,如果未能解决你的问题,请参考以下文章