2012-05-02 15 views
1

所以在UITableViewCell子这个伟大的工程:iOS5的变化蓝色小区选择自定义图像梯度没有子

- (void)awakeFromNib { 
    [super awakeFromNib]; 
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"table-highlight.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]]; 
    imageView.contentMode = UIViewContentModeScaleToFill; 
    self.selectedBackgroundView = imageView; 
} 

但是我只是用未子类标准表细胞的tableView。我试过各种各样的组合,如在其他答案中找到没有运气:

if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; 
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"table-highlight.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]]; 
    imageView.contentMode = UIViewContentModeScaleToFill; 
    cell.selectedBackgroundView = imageView; 
} 

回答

1

该死的。发帖后30秒想到一件事。留下它以防别人帮助别人。我的imageView没有框架。工作代码:

if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; 
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"table-highlight.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]]; 
    imageView.frame = cell.frame; 
    imageView.contentMode = UIViewContentModeScaleToFill; 
    cell.selectedBackgroundView = imageView; 
} 
+0

一定要标记您的答案的答案,因此在搜寻结果中的回答。 –

+0

我会的。必须等待2天。 –

+0

大声笑说,鲍勃去年以前^^ – mafiOSo