I'm using the code below in my view controller but the background image is not showing. Any idea what could be the issue?
(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell-background.png"]];
/* I also tried: cell.backgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell-background.png"]]; */
}
Thx for helping,
Stephane
Shooting in the dark, but have you tried
cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell-bacground.png"]];
or perhaps you misspelled background in the image path? ;-)
UIImageView *theImageView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"someImage.png"]; [theImageView setFrame:SomeRect]; [[cell contentView] setBackgroundView:theImageView]; [theImageView release];
That will work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.