UILabel 没有显示我的所有文本,也没有显示更多 (...)

发布于 2024-12-02 14:36:22 字数 311 浏览 1 评论 0原文

我正在动态确定单元格的高度,以适应我的所有文本。

我还将行数设置为 0。

大多数情况下它都有效,但有时我会得到这样的结果:

在此处输入图像描述

文本比显示的多,即使我记录标签文本,它显示的内容也比显示的内容多。

黑框用于表明框架足够大,可以容纳文本,但由于某种原因,标签拒绝显示我的所有文本。

有人经历过这样的事情吗?

谁能帮我解决这个问题吗?

我知道这并不复杂,但它让我发疯。

I am determining the height of my cells dynamically, to fit all my text.

I also set the number of lines to 0.

It works most of the time but sometimes I get things like this:

enter image description here

There is more text than is shown, and even if I log the label text, it shows more that what is being displayed.

The black frame is used to show that the frame is big enough to hold the text but for some reason the label refuses to show all my text.

Has anyone experienced anything like this?

Can anyone help me solve this?

I know it's not complicated but its been driving me crazy.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心如狂蝶 2024-12-09 14:36:22

在这种情况下,使用正确的函数来测量文本的大小非常重要。查看此博客文章:iPhone SDK中计算多行文本的高度

In this instance, it is very important to use the correct function to measure the size of your text. Check out this blog post: Calculating Height of Multi-Line Text on the iPhone SDK.

总攻大人 2024-12-09 14:36:22

解决方案其实很简单,由于某种原因,行数被改变了,所以现在我只确保在单元格显示之前,标签的行数实际上是0。

谢谢大家的帮助!

The solution was actually very simple, for some reason, the number of lines was being changed, so now I only make sure that before the cell is displayed, the number of lines for the label is in fact 0.

Thank you all for the help!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文