Dynamic UITableViewCell content does not expand cell

不问归期 提交于 2019-11-29 16:36:51

It seems you have set your constraints correctly, just make sure that delegates are as below:

-(CGFloat)tableView:(UITableView *)tableView
estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 44;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
   return UITableViewAutomaticDimension;
}

(If your constraints are set correctly from top to bottom)And that's it, you dont have to do anything else, auto layout will do its work smartly.

In addition to Auto-Layout constraint
try
cell.contentView.LayoutIfNeeded statement in cellForRowIndexPath just before returning cell and HeightForRowAtIndexPath method

If you're sure all your vertical constraints are set and correct top to bottom, try setting tableView.rowHeight = UITableViewAutomaticDimension explicitly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!