我有一个将动态数据加载到 TableView 中的应用程序。当只有一项时(因此只有一个单元格)。为了确保 UITableViewCellSeperator 不会针对这一项显示,我使用以下代码:
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
// This will create a "invisible" footer
return 0.01f;
}
这按预期工作,这是我的单元格的样子:
正如您所看到的,这按预期工作,并且没有单元格分隔符。
当我选择单元格并显示详细 View ,然后单击后退按钮时,单元格由于某种原因添加了分隔符。这是我导航回堆栈后单元格的样子:
您会注意到分隔符现在比标准分隔符更宽。如果我的表格 View 中有多个单元格,则表格 View 中的最后一个单元格的行为方式相同。
当我删除上述方法时,问题得到解决,但现在我的表格 View 有大量用于空单元格的额外分隔符。有更好的解决方案吗?
这是我的 cellForRowAtIndexPath 方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"searchCell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}
// Configure the cell...
cell.backgroundColor = [UIColor PFBlack];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.font = [MuseoSans font500WithSize:16.0f];
cell.textLabel.textColor = [UIColor whiteColor];
cell.textLabel.text = @"Current Location";
return cell;
}
知道是什么导致了这个问题吗?或者我做错了什么?谢谢!
最佳答案
关于uitableview - 从堆栈弹出后重新出现 UITableViewCellSeperator 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21273709/