Skip to content

Instantly share code, notes, and snippets.

@qy1010
Created June 13, 2019 08:29
Show Gist options
  • Save qy1010/51671e8e27fd7a0e77bd73dc43dcfa3b to your computer and use it in GitHub Desktop.
Save qy1010/51671e8e27fd7a0e77bd73dc43dcfa3b to your computer and use it in GitHub Desktop.
TableView高度自动调节
[self.KVOController observe:self.xxxx keyPath:FBKVOKeyPath(((UITableView *)_chatView).contentSize) options:NSKeyValueObservingOptionNew block:^(id _Nullable observer, id _Nonnull object, NSDictionary<NSString *,id> * _Nonnull change) {
UITableView *xxxx1 = (UITableView *)object;
CGFloat heightT = xxxx1.contentSize.height;
CGFloat maxHeight = 200;
if (heightT > maxHeight) {
heightT = maxHeight;
}
[self.xxxx mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(heightT).priority(900);
}];
[self.view setNeedsLayout];
[self.view layoutIfNeeded];
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment