Created
June 13, 2019 08:29
-
-
Save qy1010/51671e8e27fd7a0e77bd73dc43dcfa3b to your computer and use it in GitHub Desktop.
TableView高度自动调节
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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