How can I make the iPhone 4 LED light fire instantly?

前端 未结 2 2033
悲哀的现实
悲哀的现实 2020-12-15 11:02

I\'m currently using the below code to turn on and off my iPhone 4 LED light and it\'s working great, but the only problem is that every time I turn the LED on there is a sl

相关标签:
2条回答
  • 2020-12-15 11:29

    Do everything (all the session and device configuration stuff) except the flash configuration block before you want to turn the flash LED on, during app init or view load.

    Then just set torch mode on when you want to turn the LED on. Something like:

    [self.myDevice lockForConfiguration:nil];
    [self.myDevice setTorchMode:AVCaptureTorchModeOn];
    [self.myDevice setFlashMode:AVCaptureFlashModeOn];
    [self.myDevice unlockForConfiguration];
    

    Make sure that myDevice is a properly configured property during your init.

    0 讨论(0)
  • 2020-12-15 11:36

    A bit necromantic, but here is a great Library to do it :

    LARSTTorch

    0 讨论(0)
提交回复
热议问题