如果太长,带有滚动视图的 UIlabel 换行符无法正确显示(iPhone 视网膜模拟器)
我有 UIlabel 使用下面的代码,我不知道它是否太长。但是当它滚动时, uilabel 会得到这个结果。我该如何解决这个问题?使用 uilabel 有什么限制吗?
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 模拟器时会出现此问题。
i have UIlabel using below code, i don't know maybe its too long or not. but when it is scrolled, the uilabel get this result. How can i solve the problem? are there any limitation using uilabel?
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));
Edit:
This problem occur when i use Iphone Retina simulator.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它看起来就像标签相互叠加。您可以尝试将其
backgroundColour
设置为[UIColor clearColor]
并将其opaque
属性设置为NO
以检查它是否是确实如此。如果是,那么您将必须检查您的框架设置代码。如果整个内容是一个标签,那么您可能不希望单个标签包含这么多行,但您可以尝试调用 setNeedsDisplay 来强制重绘。
It looks like labels overlaying on top of each other. You can try setting their
backgroundColour
to[UIColor clearColor]
and theiropaque
property toNO
to check that it is indeed the case. If it is then you will have to check your frame setting code.If the whole thing is one label then you probably don't want a single label with so many lines, but you can try calling
setNeedsDisplay
to force redrawing.