如果太长则无法正确显示带有scrollview的UIlabel换行符(iphone视网膜模拟器)

时间:2011-11-11 13:51:25

标签: iphone objective-c uiscrollview uilabel

我使用下面的代码使用UIlabel,我不知道它可能太长或没有。但当它滚动时,uilabel得到了这个结果。我该如何解决这个问题?使用uilabel有什么限制吗?

Picture

CGSize maximumLabelSize = CGSizeMake(100,9999);
CGSize expectedLabelSize = [summaryBlogParsed sizeWithFont: contentSummaryLabel.font 
                                         constrainedToSize:maximumLabelSize 
                                             lineBreakMode: contentSummaryLabel.lineBreakMode]; 

//adjust the label the the new height.
CGRect newFrame = contentSummaryLabel.frame;
newFrame.size.height = expectedLabelSize.height;
contentSummaryLabel.frame = newFrame;
contentSummaryLabel.numberOfLines = 0;
contentSummaryLabel.text = summaryBlogParsed;

[contentSummaryLabel sizeToFit];
contentScrollView.contentSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*2 + CGRectGetMaxY(contentSummaryLabel.frame));

编辑: 当我使用Iphone Retina模拟器时会出现此问题。

1 个答案:

答案 0 :(得分:1)

看起来标签叠加在彼此之上。您可以尝试将backgroundColour设置为[UIColor clearColor],将opaque属性设置为NO,以确定情况确实如此。如果是,那么您将必须检查您的帧设置代码。

如果整个标签是一个标签,那么您可能不希望单个标签包含这么多行,但您可以尝试调用setNeedsDisplay来强制重绘。