zoukankan      html  css  js  c++  java
  • 相册权限 第一次安装、用户是否授权

    void (^allowEvent)() = ^{

            UIImagePickerControllerSourceType sourceType;

            sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

            UIImagePickerController *picker = [[UIImagePickerController alloc]init];

            picker.delegate = self;

            picker.sourceType = sourceType;

            picker.allowsEditing = YES;

            UIViewController *ctl = [[[UIApplication sharedApplication] windows]lastObject].rootViewController;

            [ctl presentViewController:picker animated:YES completion:nil];

        };

        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {

            PHAuthorizationStatus author = [PHPhotoLibrary authorizationStatus];

            if (author == PHAuthorizationStatusNotDetermined) {

                [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {

                    dispatch_async(dispatch_get_main_queue(), ^{

                        if (status == PHAuthorizationStatusAuthorized) {

                            allowEvent();

                        }else{

                            showAlert(@"用户取消相册授权,请在设置中启用");

                        }

                    });

                }];

                return;

            }else if(author == PHAuthorizationStatusRestricted || author == PHAuthorizationStatusDenied){

                showAlert(@"相册权限受限,请在设置中启用");

                return;

            }

            allowEvent();

        }

  • 相关阅读:
    【Base64】用 js 编 解 码 base64
    【ecshop】调用购物车商品数量
    【LNMP】 fileinfo扩展安装
    【Twitter接口】网站嵌入推特信息
    【新浪微博接口】网站接入微博秀
    【Node.js】Mac 下安装node图文详解
    【Select2】带搜索框的下拉框美化插件
    Java中食之无味弃之可惜的数组
    当我谈过年时,我该谈些什么?
    我没回老家过春节的那4点原因
  • 原文地址:https://www.cnblogs.com/AlvinCrash/p/5379428.html
Copyright © 2011-2022 走看看