KVO observer with #keyPath(UIView.isHidden)
does not work, but "hidden"
works.
Very strange. Is it bug or feature?
child.addObserver(self, forKeyPath: "hidden", options: [.initial,.new], context: nil);
override func observeValue(forKeyPath keyPath: String?, of object: Any?, .change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if let view = object as? UIView, view.superview === self && keyPath == "hidden" {
print("*");
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…