Asking camera permission on iPad

后端 未结 1 574
长发绾君心
长发绾君心 2021-01-14 19:47

In an app, I\'m currently taking a picture only after camera permissions have been checked, as follows:

AVAuthorizationStatus authStatus = [AVCaptureDevice a         


        
1条回答
  •  爱一瞬间的悲伤
    2021-01-14 20:47

    You need to request for permission using the following code:

    AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
    if(authStatus == AVAuthorizationStatusAuthorized)
    {
        // Take picture
    }
    else
    {
        [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)
        {
           if (granted)
           {
               NSLog(@"User Granted");
           }
           else
           {
               NSLog(@"User Denied");
           }
        }];
    }
    

    0 讨论(0)
提交回复
热议问题