Commit 6861cf66 authored by Zhen Tan's avatar Zhen Tan Committed by GitHub

Merge pull request #353 from hsjcom/master

相册授权修改
parents 2ed793fa 318add53
......@@ -57,7 +57,15 @@ static CGFloat TZScreenScale;
/// Return YES if Authorized 返回YES如果得到了授权
- (BOOL)authorizationStatusAuthorized {
return [self authorizationStatus] == 3;
NSInteger status = [self authorizationStatus];
if (status == 0) {
/**
* 当某些情况下AuthorizationStatus == AuthorizationStatusNotDetermined时,无法弹出系统首次使用的授权alertView,系统应用设置里亦没有相册的设置,此时将无法使用,故作以下操作,弹出系统首次使用的授权alertView
*/
[self requestAuthorizationWhenNotDetermined];
}
return status == 3;
}
- (NSInteger)authorizationStatus {
......@@ -69,6 +77,21 @@ static CGFloat TZScreenScale;
return NO;
}
//AuthorizationStatus == AuthorizationStatusNotDetermined 时询问授权弹出系统授权alertView
- (void)requestAuthorizationWhenNotDetermined {
if (iOS8Later) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
dispatch_async(dispatch_get_main_queue(), ^{
});
}];
});
} else {
[self.assetLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
} failureBlock:nil];
}
}
#pragma mark - Get Album
/// Get Album 获得相册/相册数组
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment