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

        }

  • 相关阅读:
    深入学习Spring框架(四)- 事务管理
    深入学习Spring框架(三)- AOP面向切面
    深入学习Spring框架(二)- 注解配置
    深入学习Spring框架(一)- 入门
    深入学习Mybatis框架(二)- 进阶
    深入学习Mybatis框架(一)- 入门
    短uuid生成
    from __future__ import division
    django-orm 快速清理migrations缓存
    Ajax请求设置csrf_token
  • 原文地址:https://www.cnblogs.com/AlvinCrash/p/5379428.html
Copyright © 2011-2022 走看看