yue1liang1chuan 2013-01-15 06:55 采纳率: 0%
浏览 1895

UIImageView全部充填UITableViewCell

怎么实现整个UITableViewCell充填一个自定义图片?我需要在原型设计里面实现,但是不知道怎么做,我用了三个UITableViewCell,都用同一个图片,不知道怎么实现?

  • 写回答

1条回答

  • abcdeFGh_xyz 2013-01-15 08:34
    关注

    两种方法:
    第一

      -(void)  tableView:(UITableView*)tableView 
           willDisplayCell:(UITableViewCell*)cell 
         forRowAtIndexPath:(NSIndexPath*)indexPath;
        {
            static UIImage* bgImage = nil;
            if (bgImage == nil) {
                bgImage = [[UIImage imageNamed:@"myimage.png"] retain];
            }
            cell.backgroundView = [[[UIImageView alloc] initWithImage:bgImage] autorelease];
        }
    

    第二种更简单

    ((UIImageView*)cell.backgroundView).image = [UIImage imageNamed:@"customBackground"];
    ((UIImageView*)cell.selectedBackgroundView).image = [UIImage imageNamed:@"selectedBackground"];
    
    评论

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗