0

我已经为表格视图中的单元格设置了图像,但没有显示分隔单元格的线条。我做错了什么?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *mbTableIdentifier = @"SimpleTableItem";
    UIImageView *image = [[UIImageView alloc]init];
    image.image = [UIImage imageNamed:@"BarButton.png"];

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:mbTableIdentifier];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:mbTableIdentifier];
        cell.textLabel.font=[UIFont systemFontOfSize:16.0];
    }

    // cell.backgroundView = [[CustomCellBackground alloc] init];
    cell.selectedBackgroundView = [[CustomCellBackground alloc] init];
    cell.textLabel.backgroundColor = [UIColor clearColor];
    cell.textLabel.highlightedTextColor = [UIColor darkGrayColor];
    cell.textLabel.textColor = [UIColor whiteColor];
    cell.backgroundView = image;

    cell.textLabel.text = [mbTableData objectAtIndex:indexPath.row];
    return cell;
}

编辑:我已经记录了我的分隔符样式和颜色

2013-05-20 07:28:40.392 KFBNewsroom[1274:c07] 单元格分隔符样式:2 分隔符颜色:UIDeviceRGBColorSpace 0.67 0.67 0.67 1 2013-05-20 07:28:40.393 KFBNewsroom[1274:c07] 单元格分隔符样式:2分隔符颜色:UIDeviceRGBColorSpace 0.67 0.67 0.67 1 2013-05-20 07:28:40.393 KFBNewsroom[1274:c07] 单元格分隔符样式:2 分隔符颜色:UIDeviceRGBColorSpace 0.67 0.67 0.67 1

编辑:问题的截图 在此处输入图像描述

编辑:我最终通过在图像底部添加一条 1 像素线来解决问题。

4

3 回答 3

0

通过编码设置 tableView 的属性

yourTableView.separatorStyle=UITableViewCellSeparatorStyleSingleLine;  

使用 xib

在此处输入图像描述

或者增加你的 tableView 行高(超过你的图像高度)

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 100;
}
于 2013-05-20T08:52:39.873 回答
0
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   return 50;
}

此委托方法用于增加 tableview 单元格的高度。你可以试试这个。

于 2013-05-20T04:41:57.757 回答
0

转到 XIB 中的 tableview 属性,检查分隔符是否已设置为“无”。在这种情况下,您需要从下拉菜单中将其设置为“单行”..

于 2013-05-20T05:31:04.087 回答