简体   繁体   English

表细胞图像背景没有显示

[英]Table cell image background not showing

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"]; UIImageView * theImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@“someImage.png”]; [theImageView setFrame:SomeRect]; [theImageView setFrame:SomeRect]; [[cell contentView] setBackgroundView:theImageView]; [[cell contentView] setBackgroundView:theImageView]; [theImageView release]; [theImageView release];

That will work. 那可行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM