Ask permission to access Camera Roll

后端 未结 7 1256
生来不讨喜
生来不讨喜 2020-11-28 22:39

I have a settings view where the user can choose switch on or off the feature \'Export to Camera Roll\'

When the user switches it on for the first time (and

相关标签:
7条回答
  • 2020-11-28 23:11
    #import <AssetsLibrary/AssetsLibrary.h>
    

    //////

    ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
        switch (status) {
            case ALAuthorizationStatusRestricted:
            {
                //Tell user access to the photos are restricted
            }
    
                break;
            case ALAuthorizationStatusDenied:
            {
                // Tell user access has previously been denied
            }
    
                break;
    
            case ALAuthorizationStatusNotDetermined:
            case ALAuthorizationStatusAuthorized:
    
                // Try to show image picker
                myPicker = [[UIImagePickerController alloc] init];
                myPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
                myPicker.delegate = self;
                [self presentViewController: myPicker animated:YES completion:NULL];
                break;
    
    
            default:
                break;
        }
    
    0 讨论(0)
提交回复
热议问题