【问题标题】:Setting backgroundView of UITableView cell设置 UITableView 单元格的 backgroundView
【发布时间】:2011-08-17 00:37:39
【问题描述】:

我正在设置 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 有效。我是不是做错了什么?

【问题讨论】:

    标签: objective-c xcode uitableview uiimageview


    【解决方案1】:

    不应该进行类型转换。

    解决方法是设置一个UIImageView图片,然后直接设置。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      • 2013-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多