2009-12-07 3 views
3

배경 이미지를 차단하는 내 UITableViewCell 레이블 안에 문제가 있습니다. 그것은 선택되지 않은 상태에서만 일어나는 것처럼 보입니다. 배경색을 지우려고했으나 그렇게하지 않았습니다. 그것은 tableview의 배경색을 채택하고 있습니다. 레이블 배경 이미지도 설정해야합니까? 여기 UITableViewCell 차단 배경의 레이블

screen shot

// Neither of these worked... 
cell.textLabel.backgroundColor = [UIColor clearColor]; 
cell.contentView.backgroundColor = [UIColor clearColor]; 
cellForRowAtIndexPath

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SimpleTableIdentifier"]; 
    if (cell == nil) 
    { 
     cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"SimpleTableIdentifier"] autorelease]; 
    } 

    UIImage *image = [UIImage imageNamed:@"TableRow.png"]; 
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; 
    imageView.contentMode = UIViewContentModeScaleToFill; 
    cell.backgroundView = imageView; 
    [imageView release]; 

    UIImage *imageSelected = [UIImage imageNamed:@"TableRowSelected.png"]; 
    UIImageView *imageViewSelected = [[UIImageView alloc] initWithImage:imageSelected]; 
    imageViewSelected.contentMode = UIViewContentModeScaleToFill; 
    cell.selectedBackgroundView = imageViewSelected; 
    [imageViewSelected release]; 


    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    cell.textLabel.textColor = [UIColor whiteColor]; 
    cell.textLabel.text = [[self.trivia.questionsets objectAtIndex:indexPath.row] valueForKeyPath:@"title"]; 

    return cell; 
} 

UPDATE입니다 : 일종의 해결 ... 내가 가정 테이블의 배경 색상을 (설정하면

것 모든 것 아래에 있음)을 지우고, 갑자기 내 이미지가 내가 어디에서 보여지는지를 보여 주지만, 테이블 뒤로 땅이 이제 모든 것 위에 보여줍니다. 이것은 예상 된 행동입니까? 나는 테이블 및 취소 셀의 배경 색상을 모두 설정하면

tableView.backgroundColor = [UIColor redColor]; 
cell.contentView.backgroundColor = [UIColor orangeColor]; 
cell.textLabel.backgroundColor = [UIColor yellowColor]; 

screen shot 2

을 (아직이의 문서를 확인하지 않은 경우) ... 그리고 마무리, 우리는 좋은입니다. textlabel 배경색은 아무런 차이가 없습니다.

screen shot 3

+0

사용중인 기본 sdk는 무엇입니까? 그리고 어떻게 당신의 세포의 텍스트를 설정하고 있습니다 –

+0

SDK 3.1.2, 위의 질문에 내 전체 cellForRowAtIndexPath를 붙이고 있습니다 – rob5408

+1

@Spooky, 이미지 고쳐 주셔서 감사합니다! – rob5408

답변

0

그래가 예상되는 행동

tableView.backgroundColor = [UIColor clearColor]; 
cell.contentView.backgroundColor = [UIColor clearColor]; 
cell.textLabel.backgroundColor = [UIColor yellowColor]; 
.

당신의 tableview는 다른 모든 것 앞에 놓이는 서브 뷰입니다. 테이블 뷰 (즉, 배경) 앞에 무언가가 있다면 테이블을 가릴 것입니다.