它接缝,有在那里不闪功能,所以(只?)可能进行闪光灯使用计时器。
- (IBAction)doFlash:(id)sender {
if(self.videoDevice.hasTorch) {
flashCounter = 0;
[NSTimer scheduledTimerWithTimeInterval: 0.1
target:self
selector:@selector(flashLightTicker:)
userInfo:nil
repeats: YES];
}
}
- (void)flashLightTicker:(id)sender {
[self.videoDevice lockForConfiguration:nil];
if(flashCounter == 0) {
[self.videoDevice setTorchModeOnWithLevel: 0.1 error: nil];
}
if(flashCounter == 5) {
[self.videoDevice setTorchMode: AVCaptureTorchModeOff];
}
if(flashCounter == 7) {
[self.videoDevice setTorchModeOnWithLevel: AVCaptureMaxAvailableTorchLevel error: nil];
}
if(flashCounter >= 10) {
[self.videoDevice setTorchMode: AVCaptureTorchModeOff];
[sender invalidate];
}
[self.videoDevice unlockForConfiguration];
flashCounter++;
}
这也是我的想法,但我认为整个机制比似乎更复杂,因为所有事情都需要以特定方式进行计时。 – 2013-04-23 09:51:45