2016-09-13 42 views
0

不知道该怎么办。我打电话给谁/我该怎么做才能解决这个问题? AVFoundations节目指南有一个hasFlash并且支持flashmode功能,但它们不能正常工作。前置摄像头应返回false,但返回true。当不存在闪光灯时,AVCaptureDevice.hasFlash对前置摄像头返回true

if flash && AVCaptureDevicePosition.Front == currentCamera.position{ 
      if currentCamera.hasFlash && currentCamera.isFlashModeSupported(.On){ 
      if let _ = try? currentCamera.lockForConfiguration() { 
       currentCamera.flashMode = .On 
       currentCamera.unlockForConfiguration() 
       let videoConnection = stillImageOutput!.connectionWithMediaType(AVMediaTypeVideo) 
       stillImageOutput?.captureStillImageAsynchronouslyFromConnection(videoConnection, completionHandler: process) 
      } 
     } 
} 

回答

0

您可以检查一样,

AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 
BOOL hasFlash = [device hasFlash]; 

if (hasFlash) { 
    NSLog(@"device has a flash"); 
} 

else{ 

    NSLog(@"device hasn't flash"); 
} 
+0

谢谢你,但是我觉得defaultDevice是backCamera和hasFlash将返回false(这对我来说返回false)。这是问题的前置摄像头。 hasFlash对前置摄像头返回true。我不认为前置摄像头有闪光灯(我认为hasFlash应该为前置摄像头返回false)。 – jDoe

+0

显示你的代码,你如何区分前摄像头与后方? – Lion

+0

如果Flash && AVCaptureDevicePosition.Front == currentCamera.position 如果currentCamera.hasFlash && currentCamera.isFlashModeSupported(。上) 如果让_ =试试? currentCamera.lockForConfiguration(){ currentCamera.flashMode =。对 currentCamera.unlockForConfiguration() 让videoConnection = stillImageOutput .connectionWithMediaType(AVMediaTypeVideo)stillImageOutput .captureStillImageAsynchronouslyFromConnection(videoConnection,completionHandler:过程)!? } – jDoe

相关问题