PHAuthorizationStatus authStatus = [PHPhotoLibrary authorizationStatus];
if(authStatus == PHAuthorizationStatusNotDetermined) {
//如果不加这个,就会既有自定义弹窗和系统弹窗
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
if (status == PHAuthorizationStatusNotDetermined) {
[self successSaveLibraryNetworkWithIsSaveLibrary:NO];
} else if (status == PHAuthorizationStatusRestricted) {
[self successSaveLibraryNetworkWithIsSaveLibrary:NO];
} else if (status == PHAuthorizationStatusDenied) {
[self successSaveLibraryNetworkWithIsSaveLibrary:NO];
} else {
}
}];
}else if (authStatus == PHAuthorizationStatusDenied || authStatus == PHAuthorizationStatusRestricted){
[self userCustomWindowForNotOpenLibrary];
}else
{
[self successSaveLibraryNetworkWithIsSaveLibrary:YES];
}
// UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"需要你的图库的权限" preferredStyle:UIAlertControllerStyleAlert];
// UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
// //do something
// }];
// UIAlertAction *requestAction = [UIAlertAction actionWithTitle:@"同意" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
// dispatch_async(dispatch_get_global_queue(0, 0), ^{
// [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
// if (status == PHAuthorizationStatusAuthorized) {
// NSLog(@"用户同意授权相册");
// }else {
// NSLog(@"用户拒绝授权相册");
// }
// dispatch_async(dispatch_get_main_queue(), ^{
// //do something
// });
// }];
//
// });
// }];
// [alert addAction:cancelAction];
// [alert addAction:requestAction];
// [self presentViewController:alert animated:YES completion:nil];
网友评论