gpt4 book ai didi

iphone - 如何打开 iphone 4 上的 LED 灯?

转载 作者:行者123 更新时间:2023-12-03 21:11:16 25 4
gpt4 key购买 nike

Possible Duplicate:
Turn on torch/flash on iPhone 4

我只想能够打开 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];
}
}
}

关于iphone - 如何打开 iphone 4 上的 LED 灯?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3155047/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com