Swift 3
Benim UIViewController içinde
senin AVCaptureDevice
örneğinde
Seti odak modu:
do {
try videoCaptureDevice.lockForConfiguration()
videoCaptureDevice.focusMode = .continuousAutoFocus
videoCaptureDevice.unlockForConfiguration()
} catch {}
gözlemci ekleyin:
videoCaptureDevice.addObserver(self, forKeyPath: "adjustingFocus", options: [.new], context: nil)
geçersiz kılma observeValue
:
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
guard let key = keyPath, let changes = change else {
return
}
if key == "adjustingFocus" {
let newValue = changes[.newKey]
print("adjustingFocus \(newValue)")
}
}
Bu da, otomatik odaklama başarısız olduğunu söylemez. AdjustFocus ayarı yanlış olsa bile, kameranın odakta olduğu anlamına gelmez. –
Bu yöntem, iPhone 6/6Plus/6S/6S Plus sınıfı aygıtlarda da başarısız oluyor, çünkü ayarlamaFocus'un doğru olmadığı farklı bir otomatik netleme modu var. –
ISO anahtarının değeri nedir? – Nil