NSArray *captureDeviceType = @[AVCaptureDeviceTypeBuiltInWIDeAngleCamera,AVCaptureDeviceTypeBuiltInMicrophone];AVCaptureDevicediscoverySession *captureDevice = [AVCaptureDevicediscoverySession discoverySessionWithDeviceTypes:captureDeviceType mediaType:AVMediaTypeVIDeo position:AVCaptureDevicepositionUnspecifIEd];NSArray *deviceList = [captureDevice devices];AVCaptureDevice *selectedCamera = [deviceList objectAtIndex:(NSUInteger)currentCameraDeviceIndex];if ( [selectedCamera isFlashModeSupported:AVCaptureFlashModeauto] ){ [selectedCamera setFlashMode:AVCaptureFlashModeauto]; // AVCaptureFlashModeauto }
但在iOS 10中,isFlashModeSupported和setFlashMode方法已被弃用.
Xcode建议使用AVCapturePhotoOutput的-supportedFlashModes.
有什么想法如何使用上述方法?
提前致谢
解决方法 使用此代码.这非常有效.AVCaptureSession *session = [[AVCaptureSession alloc] init];[session setSessionPreset:AVCaptureSessionPresetPhoto];AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVIDeo];AVCaptureDeviceinput *deviceinput = [AVCaptureDeviceinput deviceinputWithDevice:device error:&error];if ([device hasFlash]) { [device lockForConfiguration:nil]; device.flashMode = AVCaptureFlashModeauto; [device unlockForConfiguration];}总结
以上是内存溢出为你收集整理的objective-c – AVCaptureDevice isFlashModeSupported已弃用iOS 10全部内容,希望文章能够帮你解决objective-c – AVCaptureDevice isFlashModeSupported已弃用iOS 10所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)