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

        }

  • 相关阅读:
    jQuary学习の三の效果展示
    jQuary学习の二の语法
    jQuary学习の一の初期准备
    js备战春招の四のjs函数
    javascript JSON
    js备战春招の四の表单
    js备战春招の四の严格模式
    290. Word Pattern--Easy
    546. Remove Boxes--Hard
    牛客网-华为-2020届校园招聘上机考试-3
  • 原文地址:https://www.cnblogs.com/AlvinCrash/p/5379428.html
Copyright © 2011-2022 走看看