让我们缩短 cell.textLabel 的长度
我有一个带有一些表格的应用程序。
此表中有两个标签 - 带标题的 textLabel
和带日期的 detailTextLabel
。但是当标题很长时,它会显示在 detailTextLabel
上。
我该如何解决这个问题?
附注
我尝试以这种方式重写 layoutSubviews
方法:
- (void)layoutSubviews {
[super layoutSubviews];
CGSize size = self.bounds.size;
CGRect frame = CGRectMake(4.0f, 4.0f, size.width, size.height);
self.textLabel.frame = frame;
self.textLabel.contentMode = UIViewContentModeScaleAspectFit;
}
但它不起作用
I got an app with some tables.
In this table there are two labels - the textLabel
with titles and the detailTextLabel
with dates. But when title is really long, it is showed over the detailTextLabel
.
How can I solve this problem?
P.S.
I tried to override layoutSubviews
method in this way:
- (void)layoutSubviews {
[super layoutSubviews];
CGSize size = self.bounds.size;
CGRect frame = CGRectMake(4.0f, 4.0f, size.width, size.height);
self.textLabel.frame = frame;
self.textLabel.contentMode = UIViewContentModeScaleAspectFit;
}
But it doesn't work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先我创建空单元格。然后添加 UILabel 作为带有标签的子视图。并更改 UILabel 的框架
Firstly i create empty cell. Then add there UILabel as subView with tag. And change UILabel's frame