2012-05-02 16 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