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();

        }

  • 相关阅读:
    url 路径的拼接
    java 实现导出Excel文件
    window 使用频率最高的快捷键
    jeesite 框架的简单应用
    一个软件开发者的解决问题的心得——善于利用蛛丝马迹
    在linux上安装dotnetcore
    c#多线程同步之EventWaitHandle使用
    sharepoint 2013 安装
    模板模式的应用
    正则表达式的应用
  • 原文地址:https://www.cnblogs.com/AlvinCrash/p/5379428.html
Copyright © 2011-2022 走看看