Determine if the access to photo library is set or not - PHPhotoLibrary

后端 未结 11 825
误落风尘
误落风尘 2020-11-27 10:23

With the new functionality in iOS 8, if you are using a camera in the app, it will ask for permission to access the camera and then when you try to retake the pic, it asks f

11条回答
  •  遥遥无期
    2020-11-27 11:02

    I did it like this:

    - (void)requestPermissions:(GalleryPermissions)block
    {
        PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
    
        switch (status) 
        {
            case PHAuthorizationStatusAuthorized:
                block(YES);
                break;
            case PHAuthorizationStatusNotDetermined:
            {
                [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus authorizationStatus)
                {
                    if (authorizationStatus == PHAuthorizationStatusAuthorized)
                    {
                        block(YES);
                    }
                    else
                    {
                        block(NO);
                    }
                }];
                break;
            }
            default:
                block(NO);
                break;
        }
    }
    

    And i send in what I need to do as the block depending on success or failure.

提交回复
热议问题