首先要添加加头文件 

#import <Photos/Photos.h>

 

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

    controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];

    if (status == PHAuthorizationStatusRestricted || status == PHAuthorizationStatusDenied) {

        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"请在iPhone设置-隐私-照片选项中,允许XXX访问你的照片" message:nil preferredStyle:UIAlertControllerStyleAlert];

                 UIAlertAction *photoesAction = [UIAlertAction actionWithTitle:@"" style:0 handler:^(UIAlertAction * _Nonnull action) {

                     NSLog(@"");

                 }];

                 [alertController addAction:photoesAction];

                 [self presentViewController:alertController animated:YES completion:nil];

    }else{

        [self presentViewController:controller animated:YES completion:nil];

    }

 

 

posted on 2016-03-14 14:07  LiRenee  阅读(226)  评论(0编辑  收藏  举报