我有一个 UITableViewController 有 2 个具有自定义高度的原型单元格 - 一个高度为 187 点,另一个高度为 140 点。tableview 的默认行高是 ser to 187。
我的 cellForRowAtIndexPath 看起来像这样:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
MyListingCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyListingCell"];
[cell initWithListing:[self.listings objectAtIndex:indexPath.row]];
return cell;
} else {
return [tableView dequeueReusableCellWithIdentifier:@"AddMyListingCell"];
}
}
我有一个匹配的 heightForRowAtIndexPath ,如下所示:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyListingCell"];
return cell.frame.size.height;
} else {
//if no listings exist, make the cell full-screen height
if (self.listings.count == 0) {
return tableView.frame.size.height;
} else {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AddMyListingCell"];
return cell.frame.size.height;
}
}
}
当我运行代码时,单元格高度正确显示。分别为 187 和 140。
但是,我想将较大单元格的大小更改为 213 点。为此,我将自定义表格单元格的高度更改为 213。问题是当我运行代码(使用 XCode 6)时,表格单元格的高度仍然为 187。
我尝试将默认的 tableview rowheight 属性也更改为 213。但是我仍然得到 187。事实上,当我查看情节提要(作为文本)时,任何地方都没有提到 187。但似乎 XCode 正在记住以前的值。
我尝试过清理、深度清理、重新启动 xcode、从手机中删除应用程序以及删除我的调试产品。我无法忘记187。
这可能是 XCode 6 中的错误吗? 在 XCode 5 中,这不会发生(已证明)。自定义单元格高度在 XCode 5 中运行良好,但在我安装 XCode 6 后的第二天就出现了这个问题。
任何人都可以就尝试的事情提供一些建议,或者确认我不会发疯。