如何打开 iphone 4 上的 LED 灯?

发布于 2024-09-07 22:43:42 字数 270 浏览 4 评论 0原文

可能的重复:
在 iPhone 4 上打开手电筒/闪光灯

我只是希望能够打开 LED 灯。有没有一种简单的方法可以做到这一点,或者我是否需要设置手机来拍摄视频,模拟在灯亮的情况下进行视频,但不保存视频?类似的事情?谢谢。

Possible Duplicate:
Turn on torch/flash on iPhone 4

I just want to be able to turn on the led light. Is there a simple way to do this, or am I going to need to, say, set up the phone to take a video, simulate it videoing with the light on, but not save the video? Something like that? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷鸟归林 2024-09-14 22:43:42

试试这个,对我来说效果很好。

#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];
    }
  }
}

Try this, it worked fine for me.

#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];
    }
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文