Apple 表示 AVCaptureDevice
的属性 whiteBalanceMode
和 exposureMode
是 KVO 可观察的。
这是我在使用 Objective-C 工作十年后第一次使用 Swift 编程。
KVO 在 Swift 中似乎要复杂得多。
我试过这个:
var kvoWhiteBalanceObserving : NSKeyValueObservation?
@objc var capDevice : AVCaptureDevice?
稍后...
capDevice = captureDevice
self.kvoWhiteBalanceObserving = observe(\.capDevice.whiteBalanceMode, options: [.old, .new]) { object, change in
print(object.whiteBalanceMode)
}
Xcode 指向 \.
说:
Type of expression is ambiguous without more context
我如何在 swift 4 中使用 KVO?
最佳答案
这样观察:
self.kvoWhiteBalanceObserving = capDevice?.observe(\.whiteBalanceMode, options: [.old, .new]) { object, change in
print(object.whiteBalanceMode)
}
关于ios - 如何 KVO 观察 AVCaptureDevice 的 whiteBalanceMode 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54948458/