BroSimple BroSimple - 5 days ago 8x
Objective-C Question

SDWebImage blocking tableview title label

I need some help, I'm using SDWebImage to display my images in my Xcode app but I'm also trying to show text using the tableView's testLabel. But what is happening is the image is pushing the textLabel to the right, next to the image instead of being on top of the image. I'm not using a UIImageView or a label, I'm using the tableviews default imbedded imageView and textLabel. Any idea on how I can display this textLabel on top of sdwebimage's loaded image? I want to display the text at the bottom left of the cell, on top of the loaded image.

I can't post an image so I will try my best at describing what my problem looks like.

Image Description:
In the cell, there is an image with a 7px margin on each side, to the right of the image there is the textLabel showing only 2-3 characters before the rest disappearing out of the screen.

My Code:

Loading the image:

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

Loading the text:

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


Instead of setting the default cell image view, which cannot be adjusted, you can add your own image view

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

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

Then use your same code to configure imgView instead of cell.imgView, and you can customize imgView however you need!