如何打开iPhone4上的led灯?
可能重复:如何打开iPhone4上的led灯?,iphone,camera,led,iphone-4,Iphone,Camera,Led,Iphone 4,可能重复: 我只想打开led灯。有没有一个简单的方法可以做到这一点,或者我需要,比如说,设置手机拍摄视频,在灯亮的情况下模拟视频,但不保存视频?像这样的?谢谢。试试这个,它对我很管用 #import <AVFoundation/AVFoundation.h> - (void) turnTorchOn: (bool) on { Class captureDeviceClass = NSClassFromString(@"AVCaptureDevice"); if (ca
我只想打开led灯。有没有一个简单的方法可以做到这一点,或者我需要,比如说,设置手机拍摄视频,在灯亮的情况下模拟视频,但不保存视频?像这样的?谢谢。试试这个,它对我很管用
#import <AVFoundation/AVFoundation.h>
- (void) turnTorchOn: (bool) on {
Class captureDeviceClass = NSClassFromString(@"AVCaptureDevice");
if (captureDeviceClass != nil) {
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if ([device hasTorch] && [device hasFlash]){
[device lockForConfiguration:nil];
if (on) {
[device setTorchMode:AVCaptureTorchModeOn];
[device setFlashMode:AVCaptureFlashModeOn];
torchIsOn = YES;
} else {
[device setTorchMode:AVCaptureTorchModeOff];
[device setFlashMode:AVCaptureFlashModeOff];
torchIsOn = NO;
}
[device unlockForConfiguration];
}
}
}
#导入
-turnTorchOn:(bool)打开{
Class captureDeviceClass=NSClassFromString(@“AVCaptureDevice”);
if(captureDeviceClass!=无){
AVCaptureDevice*device=[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if([设备hasTorch]&&[设备hasFlash]){
[设备锁定配置:无];
如果(打开){
[设备设置器模式:AVCaptureTorchModeOn];
[设备设置FlashMode:AVCaptureFlashModeOn];
托奇森=是;
}否则{
[设备设置器模式:AVCaptureTorchModeOff];
[设备设置FlashMode:AVCaptureFlashModeOff];
托奇森=否;
}
[设备解锁配置];
}
}
}
Flash标签是为Flash编程保留的,Workflow似乎有人找到了答案。。。是的,我见过。我想他不会告诉我他是怎么做到的,但请看我的答案,以备将来参考: