使用 UITableViewCellStyleValue2 时增加 TextLabel 大小

发布于 2024-12-11 13:15:39 字数 749 浏览 3 评论 0原文

我想使用 UITableViewCellStyleValue2 但我想阻止创建自定义单元格。但是,我想增加 textLabel 大小。 当我输入 textLabel 的文本时,它有时太短。 sizeToFit 在这里不起作用。

输入文字后的结果:
在此处输入图像描述

我也尝试记录当前大小,但没有获得任何有用的详细信息: 我做了:

NSLog(@"Label frame: %f %f %f %f", cell.textLabel.frame.origin.x, cell.textLabel.frame.origin.y, cell.textLabel.frame.size.width, cell.textLabel.frame.size.height);

并得到:

2011-10-24 10:33:51.084结帐[68350:fb03]标签框架:0.000000 0.000000 0.000000 0.000000

我也尝试覆盖大小,但这不起作用:

[cell.textLabel setFrame:CGRectMake(10.0f, 14.0f, 205.0f, 15.0f)];

如何增加大小?

I would like to use UITableViewCellStyleValue2 but I would like to prevent creating a custom cell. However, I would like to increase the size of the textLabel size.
When I input the text for the textLabels, it sometimes is too short. The sizeToFit doesn't either work here.

The result after I input my text:
enter image description here

I have also tried to log the current size but don't get any useful details:
I did:

NSLog(@"Label frame: %f %f %f %f", cell.textLabel.frame.origin.x, cell.textLabel.frame.origin.y, cell.textLabel.frame.size.width, cell.textLabel.frame.size.height);

And got:

2011-10-24 10:33:51.084 checkout[68350:fb03] Label frame: 0.000000
0.000000 0.000000 0.000000

I also tried overwriting the size, but that didn't work:

[cell.textLabel setFrame:CGRectMake(10.0f, 14.0f, 205.0f, 15.0f)];

How can I increase the size?

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

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

发布评论

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

评论(2

杀お生予夺 2024-12-18 13:15:40

UITableViewCell 中的默认 UILabel *textLabel 受到严格管理。

解决此问题的最简单方法是向单元格添加您自己的标签(您不需要有子类来执行此操作)。您可以稍后使用 tag 访问标签,以便稍后修改其文本,并且如果/当您 dequeueReusableCellWithIdentifier 假设您创建它与所述标识符。

The default UILabel *textLabel in a UITableViewCell is heavily managed.

The simplest way to get around this issue is to add a label of your own to the cell (which you needn't have a subclass to do). You can use a tag to access the label later in order to modify it's text at a later point, and your label will still exist if/when you dequeueReusableCellWithIdentifier assuming that you create it with said identifier.

兲鉂ぱ嘚淚 2024-12-18 13:15:40

我认为如果你使用的是ios 5 SDK,定制很容易,只需在故事板中编辑即可。
如果ios 5中没有,我认为无法定制。

I think if you are using ios 5 SDK that customization is easy, just edit it in storyboard.
If that's not in ios 5, I think that can't be customized.

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