• 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
    
  • 相关阅读:
    属于程序员的算法
    知乎:全栈工程师讨论
    盘点2015年前20款表现出色的免费开源软件
    qt学习之路
    ubuntu联网经常掉线的解决方法
    备份书签
    linux 命令行测试网速
    linux中判断ssh是否启动
    php heredoc 与 nowdoc
    php 双向队列类
  • 原文地址:https://www.cnblogs.com/hualuoshuijia/p/11493007.html
Copyright © 2020-2023  润新知