2012-10-14 4 views
0

UITableViewCell의 UITextLabel 프레임을 설정할 수 없습니다. CGRect를 만들어 프레임으로 설정했지만 작동하지 않는 것 같습니다. 아래 코드 (색상 및 텍스트)에 설정된 UITextLabel의 다른 모든 속성은 원하는대로 렌더링됩니다.setFrame이 UITableView 셀의 UITextLabel에 대해 작동하지 않습니다.

UITableViewCell *c = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; 

     if(!c) 
     { 
      c = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; 
     } 

NSString *soundName = [[soundNames objectAtIndex:[indexPath row]] valueForKey:@"Name"]; 
     UIColor *whiteColor = [UIColor whiteColor]; 
     [[c textLabel] setTextColor:whiteColor]; 
     [[c textLabel] setText:soundName]; 
     [[c textLabel] setFont:[UIFont fontWithName:@"Gill Sans" size:17]]; 

     CGRect textLabelFrame = CGRectMake(50, 7, 270, 29); 
     [[c textLabel] setFrame:textLabelFrame]; 

     return c; 

여기에 무슨 일이 벌어 질 수 있는지에 대한 아이디어가 있으십니까?

답변

0

textLabel의 프레임은 셀이 표시 될 때마다 layoutSubviews 방법으로 변경됩니다. layoutSubviews 메소드를 무시하고 여기에 맞춤 프레임을 설정하거나 미리 정의 된 프레임이있는 UILabel을 셀에 추가하면됩니다.

관련 문제