它接縫,有在那裏不閃功能,所以(只?)可能進行閃光燈使用計時器。
- (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