Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 自定义UITableViewCells重叠?_Ios_Objective C_Uitableview - Fatal编程技术网

Ios 自定义UITableViewCells重叠?

Ios 自定义UITableViewCells重叠?,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我有5种自定义UITableViewCell。我的numberofrows也正确。但说到展示。最后两个细胞正在相互超越。 您需要动态设置单元格的高度,这可能是问题所在 使用此方法: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { CGFloat rowHeight = [self getRowHeightForRow: indexPath.ro

我有5种自定义UITableViewCell。我的numberofrows也正确。但说到展示。最后两个细胞正在相互超越。


您需要动态设置单元格的高度,这可能是问题所在

使用此方法:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
  CGFloat rowHeight = [self getRowHeightForRow: indexPath.row];
  return rowHeight;
}

使单元格的高度变大?getRowHeightForRow方法在哪里?没有这样的方法,您需要代表要显示的自定义单元格或要在该indexPath单元格中显示的内容计算高度。它们只是高度问题。就像我硬编码的CGFloat一样。问题解决了,我没有在视图中添加约束。很抱歉谢谢你的帮助:)!!
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
  CGFloat rowHeight = [self getRowHeightForRow: indexPath.row];
  return rowHeight;
}