SDWebImage 阻塞 tableview 标题标签

SDWebImage blocking tableview title label

我需要一些帮助,我正在使用 SDWebImage 在我的 Xcode 应用程序中显示我的图像,但我也在尝试使用 tableView 的 testLabel 显示文本。但是发生的事情是图像将 textLabel 推到右侧,图像旁边,而不是在图像顶部。我没有使用 UIImageView 或标签,我使用的是 tableviews 默认嵌入的 imageView 和 textLabel。关于如何在 sdwebimage 的加载图像之上显示此 textLabel 的任何想法?我想在单元格的左下角、加载的图像之上显示文本。

我无法 post 图片,所以我会尽力描述我的问题。

图片说明: 在单元格中,有一个图像,每侧边距为 7px,在图像的右侧,textLabel 仅显示 2-3 个字符,其余字符则消失在屏幕之外。

我的代码:

正在加载图像:

NSURL * imgURL = [[gamesArray objectAtIndex:indexPath.row] valueForKey:@"gameURL"];
[cell.imageView setContentMode:UIViewContentModeScaleAspectFit];
[cell.imageView sd_setImageWithURL:imgURL placeholderImage:[UIImage imageNamed:@"placeholder.png"] options:SDWebImageRefreshCached];

正在加载文本:

cell.textLabel.text = gameObject.gameName;
[cell.textLabel setContentMode:UIViewContentModeScaleToFill];
cell.textLabel.textColor = [UIColor whiteColor];

在默认情况下,TableView 单元格图像始终居中,textLabel 位于 imageView 右侧。所以为此你必须设计一个自定义的 TableView 单元格。

您可以添加自己的图像视图,而不是设置无法调整的默认单元格图像视图

CGRect frame = CGRectMake(xOffset, yOffset, width, height);

UIImageView *imgView = [UIImageView.alloc initWithFrame:frame];
[cell addSubview:imgView];

然后使用相同的代码来配置 imgView 而不是 cell.imgView,您可以根据需要自定义 imgView!