Ios 设置表格视图单元格图像

Ios 设置表格视图单元格图像,ios,uitableview,Ios,Uitableview,我已经在表格视图中为单元格设置了图像,但是分割单元格的线没有显示出来。我做错了什么 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *mbTableIdentifier = @"SimpleTableItem"; UIImageView *image = [[UIImageView all

我已经在表格视图中为单元格设置了图像,但是分割单元格的线没有显示出来。我做错了什么

- (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分隔符颜色:UIDeviceGBColorSpace 0.67 0.67 1 2013-05-20 07:28:40.393 KFBNewsroom[1274:c07]单元格分隔符样式:2分隔符颜色:UIDeviceGBColorSpace 0.67 0.67 1 2013-05-20 07:28:40.393 KFBNewsroom[1274:c07]单元格分隔符样式:2分隔符颜色:UIDeviceGBColorSpace 0.67 0.67 1

编辑:问题的屏幕截图

编辑:我最终解决了这个问题,在我的图像底部添加了一条1像素的线

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   return 50;
}
此委托方法用于增加tableview单元格的高度。
您可以尝试此操作。

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

从编码设置tableView的属性

yourTableView.separatorStyle=UITableViewCellSeparatorStyleSingleLine;  
使用xib

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


“我已经在我的表格视图中为单元格设置了图像”你在哪里做的,我在你的帖子中没有看到;对不起,错过了。那有什么问题?你没看到那张照片吗?不清楚看不到分割线与你的问题有什么关系。我只是在设置背景图像时看不到细胞分割线。在使用我创建的CustomCellBackground之前,我可以看到细胞分裂的位置。当我使用这个新的背景图像时,我看不到将一个单元格与另一个单元格分隔开来的线条。让我们看看图像的高度是多少?请对这条线条的单元格进行注释。selectedBackgroundView=[[CustomCellBackground alloc]init];你能附上截图吗?这是正在发生的事情的截图。你的手机高度和图像高度是多少?
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 100;
}