objective-c – AVCaptureDevice isFlashModeSupported已弃用iOS 10

objective-c – AVCaptureDevice isFlashModeSupported已弃用iOS 10,第1张

概述我正在使用AVCaptureDevice的实例方法“isFlashModeSupported”如下: NSArray *captureDeviceType = @[AVCaptureDeviceTypeBuiltInWideAngleCamera,AVCaptureDeviceTypeBuiltInMicrophone];AVCaptureDeviceDiscoverySession *capt 我正在使用AVCaptureDevice的实例方法“isFlashModeSupported”如下:

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所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1005933.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存