Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UILABEL中的内容重叠_Iphone_Uilabel - Fatal编程技术网

Iphone UILABEL中的内容重叠

Iphone UILABEL中的内容重叠,iphone,uilabel,Iphone,Uilabel,嗨, 我正在使用以下代码在标签上动态显示数据。工作正常。但有时内容与副标题和说明重叠。请帮助我。我无法跟踪此内容。提前感谢 for (int i=0; i<[article.subheadArray count]; i++) { //subhead Title subheadTitle = [[UILabel alloc] initWithFrame:CGRectMake(xoffset, yoffset+total, 320-xoffset, 300+l

嗨, 我正在使用以下代码在标签上动态显示数据。工作正常。但有时内容与副标题和说明重叠。请帮助我。我无法跟踪此内容。提前感谢

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];

        }

    }
for(int i=0;i=200){
高度=200;
}否则{
高度=图像大小。高度;
}
imageView=[[UIImageView alloc]initWithFrame:CGRectMake((320宽度)/2,yoffset+总计,宽度,高度)];
//imageView=[[UIImageView alloc]initWithFrame:CGRectMake(200,yoffset+总计,宽度,高度)];
imageView.clipsToBounds=是;
总计+=图像视图、帧、大小、高度+偏移量;
//************cell.myImageView.image=[XMLParser getImagewithName:@“og_logo.png”];
imageView.image=[XMLParsing getImagewithName:image.Name];
[滚动视图添加子视图:图像视图];
}
}

我认为
副标题
副标题标签
都会重叠,因为它们的
框架
。在这两种情况下,您能否检查
expectedLabelSize
的值