2016-11-21 74 views
0

我有一個相機訪問應用程序。
它直到最近纔開始工作。
可能是它關係到iOS10 ...不能請求攝像頭訪問

所以,這裏是我如何讓用戶攝像頭的訪問:

- (void)checkCameraAuthorization { 
    AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; 
    switch (status) { 
     case AVAuthorizationStatusAuthorized: { 
      break; 
     } 
     case AVAuthorizationStatusNotDetermined: { 
      dispatch_suspend(self.sessionQueue); 
      [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) { 
       // never gets here 
       dispatch_resume(self.sessionQueue); 
      }]; 
      break; 
     } 
     default: { 
      // denied or restricted; 
      isAccessible = NO; 
      [self inaccessibleCameraExit]; 
      break; 
     } 
    } 
} 

正如我已經說過這個代碼前工作過一段時間。

現在,在執行AVCaptureDevice requestAccessForMediaType:之後會拋出異常。
如果我註釋掉這個方法的調用,除了相機,一切都可以工作。

enter image description here

異常不指着我的代碼,而不是在我的線程。

那麼,你能幫我把相機還給工作狀態。

回答

4

您需要在您的info.plist添加NSCameraUsageDescription爲iOS 10,這是來自iOS的10

更新有關更多信息,請this

+0

謝謝,我在哪裏可以看一下嗎? – seelts

+0

更新了我的回答添加鏈接 – Rajat

+0

謝謝,這有幫助! – seelts