我想获得桌面视图高度,并使用KVO。我使用以下内容:
[self.selectionTableView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:NULL];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context {
if(object == self.selectionTableView && [keyPath isEqualToString:@"contentSize"]) {
[self.backgroundView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.selectionTableView.mas_bottom);
make.left.bottom.right.equalTo(self.view);
}];
NSLog(@"h? %f", self.selectionTableView.contentSize.height);
}
}
我想提一下,我还有其他表,称为表视图。但我想获得选择表视图的高度。
但是当加载表时,我可以在日志中看到以下内容:
2017-06-14 17:08:53.524 Engineering[27338:1452963] h? 1200.000000
2017-06-14 17:08:53.524 Engineering[27338:1452963] h? 1200.000000
2017-06-14 17:08:53.526 Engineering[27338:1452963] h? 1200.000000
2017-06-14 17:08:53.527 Engineering[27338:1452963] h? 1200.000000
2017-06-14 17:08:53.530 Engineering[27338:1452963] h? 834.000000
2017-06-14 17:08:53.535 Engineering[27338:1452963] h? 468.000000
2017-06-14 17:08:53.537 Engineering[27338:1452963] h? 102.000000
正确的身高是102,但我想知道其他数字来自哪里?