【发布时间】:2018-06-28 10:11:41
【问题描述】:
我想动态调整自定义单元格的高度。
在我的 tableView 中有三个自定义列:
- 产品名称
- 产品数量
- 产品价格
现在产品名称列不显示全名。它只显示任何适合的文本。但无法显示全名。
虽然我已将heightForRowAtIndexPath 设置如下:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewAutomaticDimension;
}
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewAutomaticDimension;
}
这是在我的CustomCell 类中设置的以下行
self.productNameLabel.lineBreakMode = NSLineBreakByWordWrapping;
self.productNameLabel.numberOfLines = 0;
示例:
NSString *prodName = @"This is my product name which may contain description with it";
所以在上面的例子中,我的UITableViewCell 只显示了这么多产品名称:This is my product,它转义了更多的字符串。
请参阅下面的附加属性部分和约束...
我想在Nutrient 列中设置产品名称
请帮帮我,尝试了所有可能的解决方案,但无法解决。
这样我的 uitableview 数据显示...但无法在营养素中显示全名。
【问题讨论】:
-
展示你是如何设置约束的
标签: ios objective-c uitableview row-height