【发布时间】:2015-03-17 03:52:26
【问题描述】:
我是 iOS 开发新手。尝试将标签放入 uitableviewcell 时遇到问题。文本不断从单元格中流出。我添加了所有需要的约束,但它不起作用。 这是我的设置和代码:
Title label attributes: Number of lines-0, Line breaks-Word wrap
viewDidLoad():
self.tableView.estimatedRowHeight = 68.0;
self.tableView.rowHeight = UITableViewAutomaticDimension;
cellForRowAtIndexPath():
UILabel *titleLabel = (UILabel*)[cell viewWithTag:100];
titleLabel.text = @"Why does this long text get out of the cell? The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.";
我使用的是 xcode 6.2 和 ios 8.2。
感谢您的帮助。
截图:
细胞原型:
标题标签限制:
【问题讨论】:
-
表格视图本身怎么样。它有什么样的约束?这仅适用于您使用带有表格视图的 UIViewController,而不是表格视图已设置为正确宽度的 UITableViewController。
-
@rdelmar:我正在使用 UIViewController 并手动拖入 UITableView。我应该向表格视图添加哪些约束?
-
如果你希望它是全屏的,请将其固定到超级视图的所有 4 个侧面。
标签: ios uitableview autolayout uilabel