设置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];更多推荐
发布评论