IOS8 不用计算Cell高度的TableView实现方案

这个新特性,意味着View被Autolayout调整frame后,会自动拉伸和收缩SupView。

具体到Cell,要求cell.contentView的四条边都与内部元素有约束关系。

在TableViewController里

- (void)viewDidLoad {
    [super viewDidLoad];
    
//添加这两行代码
    self.tableView.estimatedRowHeight = 44.0f;
    self.tableView.rowHeight = UITableViewAutomaticDimension;

}


搞定,不用实现任何计算Cell高度的方法,已经好了。

转载于:https://my.oschina.net/ryanzl/blog/619945

猜你喜欢

转载自blog.csdn.net/weixin_34356555/article/details/91847159