2015-02-03 4 views
0

내 문제는 this과 비슷합니다. 내 UITableViewCell Height은 (는) IOS8에서 작업 중입니다. 문제 IOS7 높이가 증가하지만 내용이 표시되지 않습니다.UITableview IOS7에서 셀 높이가 작동하지 않습니다.

내 코드는 다음과 같습니다

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
long hightmain=0; 

    if(selectIndex && indexPath.section == selectIndex.section) 
    { 

     NSString * myString = [description_vegetable_array objectAtIndex:indexPath.section]; 
     CGSize labelSize = [myString sizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:CGSizeMake(190, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping]; 
     hightmain=labelSize.height+120; 

     if (hightmain<=140) 
     { 
      btn11.frame=CGRectMake(240,100,70,17); 
      Description_LBL.frame=CGRectMake(127, 0, 190, 140); 
      BGImage.frame=CGRectMake(0, -3, 320, 140); 
     } 
     else 
     {        
      [btn11 setTitle:@"Less Info" forState:UIControlStateNormal]; 
      btn11.frame=CGRectMake(240,hightmain-30,70,17); 
      Description_LBL.frame=CGRectMake(127, -20, 190, hightmain); 
      BGImage.frame=CGRectMake(0, -3, 320, hightmain); 
      return hightmain; 
     } 
    } 
    else 
    { 
     return 140; 
    } 
} 

Description_LBL.frame=CGRectMake(127, 0, 190, 140); 내 라벨의 높이가 증가하지만 텍스트가 표시되지 ....

작동하지 않음에 iOS8의 완전한 작동하지만 iOS7에에
+0

아이폰 OS 7.0에서 사용되지 않는? –

+0

no. xib를 사용하고 자동 레이아웃이 꺼져 있습니다 –

+0

(hightmain <= 140) – Sulabh

답변

1

사용 boundingRectWithSize:을 계산하는하는있는 NSString 공공 방법 크기는 문자열 값을 기반으로합니다.

[testString boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width,MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil] 

참고 : sizeWithFont : 당신은 스토리 보드 및 자동 레이아웃을 사용하고