Background image of table cell
Posted
by Shuaib
on Stack Overflow
See other posts from Stack Overflow
or by Shuaib
Published on 2010-03-23T15:45:50Z
Indexed on
2010/03/23
16:23 UTC
Read the original article
Hit count: 341
uitableviewcell
|iphone
Hey guys,
Trying to set a background image for a table view cell, tried almost everything but failing. Hoping someone would notice what I am doing wrong. Here is how my current code looks like:
static NSString *CustomCellIdentifier = @"listCustomCell";
listCustomCell *cell = (listCustomCell *)[tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"listCustomCell"
owner:self options:nil];
for (id oneObject in nib) if ([oneObject isKindOfClass:[listCustomCell class]])
cell = (listCustomCell *)oneObject;
}
cell.backgroundColor = [UIColor clearColor];
UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"list_selected.png"]];
//[cell setBackgroundView:backgroundImageView];
cell.backgroundView = backgroundImageView;
The image won't show up in the background of the cell. All I see is plain white background.
Thanks for help.
© Stack Overflow or respective owner