我有一个NSScrollView
子类,我想NSView
根据当前滚动位置更新另一个。我尝试过 KVC 观察value
of[self horizontalScroller]
但从未被调用。
// In awakeFromNib
[[self horizontalScroller] addObserver:self
forKeyPath:@"value"
options:NSKeyValueObservingOptionNew
context:NULL];
// Later in the file
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
if (object == [self horizontalScroller] && [keyPath isEqualToString:@"value"]) {
// This never gets called
}
}
您是否在我的推理中看到错误或知道如何观察滚动的更好方法NSScrollview
?