2012-08-22 76 views
0

我的代碼在第一次在textview上寫長單詞時不起作用,那麼我的標籤大小會增加,但表格高度不會像標籤的寬度和高度一樣增加。我的代碼有什麼問題?如何根據iPad中標籤尺寸的增加來增加表格單元格行數?

我寫鑑於didload方法這兩個線路

Addresslbl = [[UILabel alloc]initWithFrame:CGRectMake(300, 10, 250, 30)]; 
    Addresslbl.backgroundColor = [UIColor whiteColor]; 

和下面的代碼寫入到-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

if(indexPath.row == 0 && indexPath.section == 3) 
     { 

       NSString *[email protected]""; 
       dispalynotes=Peopledetailmodel.Address; 
      // dispalynotes=Addresslbl.text; 
       CGSize labelSize = CGSizeMake(200.0, 20.0); 

       if ([dispalynotes length] > 0) 
        labelSize = [dispalynotes sizeWithFont: [UIFont boldSystemFontOfSize: 17.0] constrainedToSize: CGSizeMake(labelSize.width, 1000) lineBreakMode: UILineBreakModeWordWrap]; 
       return 25.0 + labelSize.height; 

     } 
+0

你有申請方法heightForRowAtIndexPath中的相同邏輯 – Rupesh

回答

0

你必須適用相同的邏輯方法heightForRowAtIndexPath

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 

if ([dispalynotes length] > 0) 
       labelSize = [dispalynotes sizeWithFont: [UIFont boldSystemFontOfSize: 17.0] constrainedToSize: CGSizeMake(labelSize.width, 1000) lineBreakMode: UILineBreakModeWordWrap]; 
      return 25.0 + labelSize.height; 

} 
相關問題