2012-03-26 131 views
0

我想知道是否可以设置一个应用程序,可以按照摩尔斯电码或SOS信号或其他类似的顺序打开和关闭相机的闪光灯。我做了一些研究,但没有发现任何结论。控制相机闪光灯iPhone

任何想法? :)

+0

鉴于App Store中有应用程序可以这样做,是的,这完全有可能。 – ceejayoz 2012-03-26 14:20:59

+0

Thx让我知道这是可能的:) – Spire 2012-03-27 08:52:42

回答

1

下面是如何打开手电筒:

AVCaptureSession *session = [[AVCaptureSession alloc] init]; 

AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error: nil]; 
[session addInput:input]; 

AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init]; 
[session addOutput:output]; 

[session beginConfiguration]; 
[device lockForConfiguration:nil]; 

[device setTorchMode:AVCaptureTorchModeOn]; 

[device unlockForConfiguration]; 
[session commitConfiguration]; 

[session startRunning]; 

并再次将其关闭:

[session stopRunning]; 

你需要与定时打开手电筒和关闭你想要使用类似NSTimer的东西。