Objective-C:如何让iphone闪光灯反复闪烁?

时间:2013-07-05 17:39:08

标签: ios objective-c xcode

瞧,我有一些代码可以打开iphone的闪光灯。但是我想闪光灯不断闪烁。这是我打开闪光灯的代码:

-(IBAction)torchon:(id)sender{

AVCaptureDevice *flashlight = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
    if ([flashlight isTorchAvailable] & [flashlight isTorchModeSupported:AVCaptureTorchModeOn]) {

        BOOL success = [flashlight lockForConfiguration:Nil];
        if(success){
            if(yes==YES){
                on.hidden = YES;
                [UIScreen mainScreen].brightness = 1.0;
                [flashlight setTorchMode:AVCaptureTorchModeOn];
                [flashlight unlockForConfiguration];

            }
 }

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:1)

我曾经开发过手电筒应用程序(是)我无事可做。你可以看看这里:

https://bitbucket.org/depl0y/illume/src

它闪烁LED并且还执行莫尔斯电码。请务必查看TorchHandler类:https://bitbucket.org/depl0y/illume/src/ad796bc62e44930623970e7d13f401ad767d97d6/Illume/Illume/Classes/TorchHandler.m?at=master

其余的你可以弄清楚自己。