【发布时间】:2014-01-22 03:37:25
【问题描述】:
我有一个将动态数据加载到表视图中的应用程序。当只有一项时(因此只有一个单元格)。为了确保 UITableViewCellSeperator 没有出现在这一项中,我使用了以下代码:
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
// This will create a "invisible" footer
return 0.01f;
}
这按预期工作,这是我的单元格的样子:
如您所见,这按预期工作,并且没有单元格分隔符。
当我选择单元格并显示我的详细视图然后点击后退按钮时,单元格出于某种原因添加了一个分隔符。这是我在堆栈中导航后单元格的样子:
您会注意到分隔符现在比标准分隔符更宽。如果我的 tableview 中有多个单元格,则 tableview 中的最后一个单元格的行为方式相同。
当我删除上述方法时,问题得到解决,但现在我的表格视图有大量用于空单元格的额外分隔符。有更好的解决方案吗?
这是我的 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 ios7 uinavigationcontroller