【问题标题】:What is this line on my UITableView?我的 UITableView 上的这条线是什么?
【发布时间】:2026-01-15 22:20:04
【问题描述】:

我有一个分组表视图。我以前做过几十个表格视图,但我不确定这条线是什么:

谁能告诉我这是什么以及如何删除它?

更新:

我将问题缩小到 heightForRowAtIndexPath 委托方法。看看下面的内容。请注意,我需要一些行更高:

-(CGFloat)tableView:(UITableView *)tableViewLocal heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if(indexPath.section == 0 && (indexPath.row == 3 || indexPath.row == 4 || indexPath.row == 5))  {
        return tableViewLocal.rowHeight * 1.3; //If I remove the multiplier, it doesn't produce the line.
    }
    else
        return tableViewLocal.rowHeight;
}

【问题讨论】:

    标签: iphone ios uitableview uikit


    【解决方案1】:

    它看起来像背景。尝试将代码中的 tableView 设置为

    self.tableView.backgroundColor = [UIColor clearColor];
    

    希望这会有所帮助。

    【讨论】:

    • 好吧,它删除了这条线,但我真的很想拥有分组的 stlye 背景。使用上面的代码基本上会给我一个白色的背景。
    • 有点老套,但如果没有其他方法,您可以在其后面放置一个 UIView,其背景颜色设置如下:view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    • 我不认为将 UIView 放在自定义 tableview 单元格后面是 hacky。听起来是个好主意。
    • 嗯,奇怪的是,即使那种 hacky 方式也不起作用......我猜我可能在 cellForRowAtIndexPath 中做错了什么。这可能吗?
    • 嗯,为什么它不起作用?你有同样的问题吗?你为什么不发布一些代码?