import UIKit
import AVFoundation
class ViewController: UIViewController {
@IBAction func buttonPressed(_ sender: UIButton) {
guard let device = AVCaptureDevice.default(for: AVMediaType.video) else {
return
}
do {
try device.lockForConfiguration()
try device.setTorchModeOn(level: 0.125)
device.unlockForConfiguration()
} catch {
print("Torch is not working.")
}
}
这是一个简单的应用程序,带有一个按钮,可将手电筒的亮度设置为0.125(不是那么亮)。在iPhone 6、7、8和X上可以使用。在iPhone XS Max上,它不起作用,而是将iPhone设置为MOST最高亮度。在极少数情况下,它会按预期工作。我一生无法弄清楚是什么导致它有时起作用,有时不起作用。
我也会在控制台上收到这些消息……只是有时会再次出现。
“” 2018-09-27 14:11:38.668495-0400 torchPractice [10925:2407801] [MC] systemgroup.com.apple.configurationprofiles路径的系统组容器为/ private / var / containers / Shared / SystemGroup / systemgroup .com.apple.configurationprofiles 2018-09-27 14:11:38.668763-0400 torchPractice [10925:2407801] [MC]从公共有效用户设置中读取。”
这可能是Apple末期的错误吗?由于类似的问题,我的应用程序“ Dozing”现在无法在新iPhone上运行。