A-Hing
6/13/2019 - 8:29 AM

TableView高度自动调节

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];
        }];