2012-03-29 44 views
1

喜的朋友,我現在如果我用這個代碼將打印標籤上的多個值,但在新的生產線我不希望像如何在的UILabel打印多值水平在iPhone

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



    CGSize labelSize = CGSizeMake(200.0, 20.0); 
    if ([displayTag length] > 0) 
     labelSize = [displayTag sizeWithFont: [UIFont boldSystemFontOfSize: 17.0] constrainedToSize: CGSizeMake(labelSize.width, 1000) lineBreakMode: UILineBreakModeWordWrap]; 
    return 24.0 + labelSize.height; 
    } 
    return 40.0; 
} 

這段代碼將打印垂直線但我想標籤上水平打印我的價值如何標籤上水平給多值打印在特定的細胞

的,我是創造,但不工作 我哪裏錯了 這個代碼在我的自定義單元格

TagsLable= [[UILabel alloc]initWithFrame:CGRectMake(360, 15, 150, 21)]; 
      TagsLable.font = [UIFont fontWithName:@"Verdana" size:16.0f]; 
      TagsLable.textAlignment=UITextAlignmentRight; 
      TagsLable.backgroundColor=[UIColor clearColor]; 



CGSize fontSize = [tagList sizeWithFont: [UIFont boldSystemFontOfSize: 17.0]]; 
     double finalWidth = fontSize.width * UIBaselineAdjustmentAlignBaselines; 
     //double finalWidth = fontSize.width + self.numberOfLines; 
     double finalHeight = self.frame.size.height; //expected height of label 
     CGSize theStringSize = [tagList sizeWithFont: [UIFont boldSystemFontOfSize: 17.0] constrainedToSize:CGSizeMake(finalWidth, finalHeight) lineBreakMode: UILineBreakModeWordWrap]; 
     int newLinesToPad = (finalWidth - theStringSize.width)/fontSize.width; 
     for(int i=0; i<newLinesToPad; i++) 
     { 
      //tagList = [tagList stringByAppendingString:@","]; 
     tagList=[tagList stringByAppendingFormat:@"%@, ",tag.TagName]; 
     } 
+0

「multipla」 ????你的意思是什麼?多重還是多重? – HarshIT 2012-03-29 06:52:08

+0

我的意思是多個值應顯示在標籤請說如何做 – Rocky 2012-03-29 07:06:07

+0

問題不明確。你能張貼你需要的照片嗎? – Gargo 2012-03-29 07:57:13

回答

0

什麼是tag.TagName

試試這個

tagList=[tagList stringByAppendingFormat:@"%@, ",tag.TagName]; 

NSString *tagList = [tagList stringByAppendingPathComponent:TagName.tag];