使用UITableViewAutomaticDimension时如何在UitableviewCell中更改UIView的高度约束 [英] How to change height Constraint of UIView in UitableviewCell when using UITableViewAutomaticDimension
本文介绍了使用UITableViewAutomaticDimension时如何在UitableviewCell中更改UIView的高度约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在UITableViewCell中有一个UIView,当用户点击更少/更多"按钮时,需要更改其高度
I have a UIView in the UITableViewCell , which needs to change its height when user taps on "less/more" button
我的代码是
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewAutomaticDimension;
}
推荐答案
将项目高度约束挂钩为IBOutlet,并在 cellForRow 中将其更改为
Hook items height constraint as IBOutlet and change it in cellForRow like this
cell.viewHeightCon.constant = // value
并且在返回单元格之前添加
and before return cell add
cell.layoutIfNeeded()
这篇关于使用UITableViewAutomaticDimension时如何在UitableviewCell中更改UIView的高度约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文