iOS APP 第一次访问相册 系统弹窗 方法的拦截

//iOS8之前 APP 第一次访问相册 系统弹窗 方法的拦截
    if ([ALAssetsLibrary authorizationStatus] == ALAuthorizationStatusNotDetermined) {
        ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc] init];
        [assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
          // 用户点击 "OK"
        } failureBlock:^(NSError *error) {
          // 用户点击 不允许访问
        }];
    }

 //iOS8之后 APP 第一次访问相册 系统弹窗 方法的拦截

 PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
    if (status == PHAuthorizationStatusNotDetermined) {
        [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
            if(status == PHAuthorizationStatusAuthorized) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    // 用户点击 "OK" 
                });
            } else {
                dispatch_async(dispatch_get_main_queue(), ^{
             // 用户点击 不允许访问
                    [self.navigationController popViewControllerAnimated:YES];
                });
            }
        }];
    }

你可能感兴趣的:(iOS APP 第一次访问相册 系统弹窗 方法的拦截)