【发布时间】:2016-05-09 05:41:28
【问题描述】:
我正在创建自定义 UITableViewCell 并以编程方式添加约束。但是我的相同文本没有在标签中调整,导致随机单元格的高度不同。我查看了各种教程并访问了其他堆栈问题的答案,但无法解决我的问题。
据我了解,这是左右标签之间的优先级问题。我在设置约束时也添加了这一行。
[righSideLabel setContentCompressionResistancePriority:950 forAxis:UILayoutConstraintAxisHorizontal];
【问题讨论】:
-
不要发布项目的链接。相反,只需使用与问题相关的代码来更新您的问题。
-
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewAutomaticDimension; } - (CGFloat)tableView:(UITableView *)tableViewestimateHeightForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewAutomaticDimension; }
-
请在你的 .m 文件中添加这两个方法
-
您是否尝试返回
heightForRowAtIndexPath中的高度? -
@rmaddy 代码在多个类中,我将尝试添加
标签: ios objective-c uitableview autolayout