How to change height Constraint of UIView in UitableviewCell when using UITableViewAutomaticDimension

和自甴很熟 提交于 2019-12-11 05:07:01

问题


I have a UIView in the UITableViewCell , which needs to change its height when user taps on "less/more" button

My code is

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

回答1:


Hook items height constraint as IBOutlet and change it in cellForRow like this

 cell.viewHeightCon.constant = // value

and before return cell add

 cell.layoutIfNeeded()


来源:https://stackoverflow.com/questions/48401654/how-to-change-height-constraint-of-uiview-in-uitableviewcell-when-using-uitablev

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