使用 UITableViewCellStyleValue2 时增加 TextLabel 大小
我想使用 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 textLabel
s, it sometimes is too short. The sizeToFit
doesn't either work here.
The result after I input my text:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
UITableViewCell
中的默认UILabel *textLabel
受到严格管理。解决此问题的最简单方法是向单元格添加您自己的标签(您不需要有子类来执行此操作)。您可以稍后使用
tag
访问标签,以便稍后修改其文本,并且如果/当您dequeueReusableCellWithIdentifier
假设您创建它与所述标识符。The default
UILabel *textLabel
in aUITableViewCell
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 youdequeueReusableCellWithIdentifier
assuming that you create it with said identifier.我认为如果你使用的是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.