When I'm running the app in iPhone 6S with iOS 11.2.2. The Flash is not working. Toggle button is working fine ie, On/Off. But, Flash is not coming when the toggle is On.
- (void)toggleFlash{
NSArray *devices = [AVCaptureDevice devices];
for (AVCaptureDevice *device in devices){
if (device.flashAvailable) {
if (flashOn){
[device lockForConfiguration:nil];
[device isTorchModeSupported:AVCaptureTorchModeOn];
[device unlockForConfiguration];
}
else{
[device lockForConfiguration:nil];
[device isTorchModeSupported:AVCaptureTorchModeOff];
[device unlockForConfiguration];
}
}
}
}
Done with the debugging.. It's working fine. But, Issue with Flash. Anyone Working on this issue. Please help me out?
Your code only checks whether torch mode is available ( isTorchModeSupported
) but never turns on the torch. You can use setTorchModeOn
for that,
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.