How do I use AVCaptureFlashMode

隐身守侯 提交于 2019-12-03 03:52:47
AVCaptureDevice* d = nil;

// find a device by position
NSArray* allDevices = [AVCaptureDevice devices];
for (AVCaptureDevice* currentDevice in allDevices) {
  if (currentDevice.position == AVCaptureDevicePositionBack) {
    d = currentDevice;
  }
}

// at this point, d may still be nil, assuming we found something we like....

NSError* err = nil;
BOOL lockAcquired = [d lockForConfiguration:&err];

if (!lockAcquired) {
   // log err and handle...
} else {
   // flip on the flash mode
   if ([d hasFlash] && [d isFlashModeSupported:AVCaptureFlashModeOn] ) {
      [d setFlashMode:AVCaptureFlashModeOn];
   }

   [d unlockForConfiguration];
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!