2011-03-11 28 views
0

HI、 ラベルに動的にデータを表示するために次のコードを使用しています.ITはうまく動作しますが、コンテンツがサブヘッドのタイトルと説明と重なっていることがあります。 ADVANCE内容はUILABELが重複しています

for (int i=0; i<[article.subheadArray count]; i++) { 

     //subhead Title 
     subheadTitle = [[UILabel alloc] initWithFrame:CGRectMake(xoffset, yoffset+total, 320-xoffset, 300+lblheight)]; 
     subheadTitle.backgroundColor=[UIColor clearColor]; 
     //subheadTitle.textColor=[UIColor blueColor]; 
     [subheadTitle setFont: [UIFont fontWithName:@"Arial-BoldMT" size:17]]; 
     subheadTitle.textColor = [UIColor colorWithRed:45.0/255.0 green:99.0/255.0 blue:03.0/255.0 alpha:1]; 
     subHead = [article.subheadArray objectAtIndex:i]; 


     expectedLabelSize = [subHead.Title sizeWithFont:subheadTitle.font 
             constrainedToSize:maximumLabelSize 
              lineBreakMode:subheadTitle.lineBreakMode]; 
     newFrame = subheadTitle.frame; 
     newFrame.size.height=expectedLabelSize.height; 
     subheadTitle.frame=newFrame;  
     total+=expectedLabelSize.height+yoffset; 
     NSLog(@"%@ %d",subHead.Title,total); 
     subheadTitle.numberOfLines=0; 
     subheadTitle.text=subHead.Title; 

     [scrollView addSubview:subheadTitle]; 

     //subhead Description 
     subheadlabel = [[UILabel alloc] initWithFrame:CGRectMake(xoffset, yoffset+total, 320-xoffset, 300+lblheight)]; 
     subheadlabel.backgroundColor=[UIColor clearColor]; 
     subHead = [article.subheadArray objectAtIndex:i]; 
     //subheadlabel.font = [UIFont italicSystemFontOfSize:fontsize]; 
     [subheadlabel setFont: [UIFont fontWithName:@"ArialMT" size:fontsize]]; 
     expectedLabelSize=[subHead.Description sizeWithFont:subheadlabel.font 
              constrainedToSize:maximumLabelSize 
               lineBreakMode:subheadlabel.lineBreakMode]; 
     newFrame = subheadlabel.frame; 
     newFrame.size.height=expectedLabelSize.height; 

     subheadlabel.frame=newFrame;  
     total+=expectedLabelSize.height+yoffset; 
     subheadlabel.text = subHead.Description; 
     NSLog(@"subhead desc: %d %d",total,subheadlabel.numberOfLines); 

     subheadlabel.numberOfLines =0; 
     [subheadlabel sizeToFit]; 
     [scrollView addSubview:subheadlabel];  

     //Adding subhead label to subheadlabelarr 
     [subheadlabelarr addObject:subheadTitle]; 

     //subhead Image 
     for (int j=0; j<[subHead.imageArray count]; j++) { 
      Image* image = [subHead.imageArray objectAtIndex:j]; 
      UIImage* uiImage = [XMLParsing getImagewithName:image.Name]; 

      CGSize imageSize = uiImage.size; 
      if(imageSize.width>=300){ 
       width = 300; 
      } 
      else { 
       width = imageSize.width; 
      } 

      if(imageSize.height>=200){ 
       height = 200; 
      }else { 
       height = imageSize.height; 
      } 


      imageView = [[UIImageView alloc] initWithFrame:CGRectMake((320-width)/2,yoffset+total,width,height)]; 
      //imageView = [[UIImageView alloc] initWithFrame:CGRectMake(200, yoffset+total, width, height)]; 
      imageView.clipsToBounds = YES; 

      total+=imageView.frame.size.height+yoffset; 
      //************cell.myImageView.image=[XMLParser getImagewithName:@"og_logo.png"]; 
      imageView.image = [XMLParsing getImagewithName:image.Name]; 
      [scrollView addSubview:imageView]; 

     } 

    } 

答えて

0

IN this.THANKSをトレースすることはできません私はsubheadTitlesubheadlabelの両方があるため、そのframeの重複すると思います。両方の場合にexpectedLabelSizeの値を確認できますか。

関連する問題