IOS8 之后UITableViewCell自动布局高度自适应

IOS8之后 如果使用自动布局,就不用再需要手动计算UITableViewCell高度

注意事项:

1.Cell高度设置自动适配,预设高度

_tableView.rowHeight = UITableViewAutomaticDimension;

_tableView.estimatedRowHeight = 134.f;

2.在重用Cell的方法中实现,不要在layoutSubviews方法里面设置布局。

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

//在这里实现布局

[self mas_makeConstraints];

}

猜你喜欢

转载自blog.csdn.net/ws_752958369/article/details/79225889