设置UITableView单元格的backgroundView(Setting backgroundView of UITableView cell)

编程入门 行业动态 更新时间:2024-10-17 05:38:03
设置UITableView单元格的backgroundView(Setting backgroundView of UITableView cell)

我正在设置UITableViewCell的背景,无论出于什么原因它都不会出现。

cell.textLabel.numberOfLines = 0; cell.textLabel.font = [UIFont fontWithName:@"Arial" size:15]; cell.textLabel.text = [[_comments objectAtIndex:indexPath.row] text]; ((UIImageView *)cell.backgroundView).image = [UIImage imageNamed:@"bubble.png"]; cell.imageView.image = [UIImage imageNamed:@"user.png"]; return cell;

除了cell.backgroundView所有东西都可以。 难道我做错了什么?

I'm setting the background of a UITableViewCell and for whatever reason it will not appear.

cell.textLabel.numberOfLines = 0; cell.textLabel.font = [UIFont fontWithName:@"Arial" size:15]; cell.textLabel.text = [[_comments objectAtIndex:indexPath.row] text]; ((UIImageView *)cell.backgroundView).image = [UIImage imageNamed:@"bubble.png"]; cell.imageView.image = [UIImage imageNamed:@"user.png"]; return cell;

Everything but the cell.backgroundView works. Am I doing something wrong?

最满意答案

不应该有类型铸造它。

解决方案是设置UIImageView图像,然后直接设置它。

UIImageView *bgView = [[UIImageView alloc] init]; (bgView).image = [UIImage imageNamed:@"bubble.png"]; cell.backgroundView = bgView; [bgView release];

Shouldn't have type casted it.

Solution was to set a UIImageView image and then set it directly.

UIImageView *bgView = [[UIImageView alloc] init]; (bgView).image = [UIImage imageNamed:@"bubble.png"]; cell.backgroundView = bgView; [bgView release];

更多推荐

本文发布于:2023-08-06 22:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1456696.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元格   UITableView   backgroundView   cell   Setting

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!