ios - UITableViewCell 中的多行标签不适用于 iOS 9 或 Swift 2.0

标签 ios swift uitableview

我正在尝试在表格 View 单元格中使用多行标签。我已经在 iOS 8 上测试了下面的代码,它工作正常并且单元格中的文本具有正确的行数。

// Make row heights adjustable
tableView.estimatedRowHeight = 44.0
tableView.rowHeight = UITableViewAutomaticDimension
multiLineCell.indentationWidth = 10.0

multiLineCell.text = "Hello, here is some text which needs to be broken down into multiple lines in order for it to be displayed."

我无法直观地指定高度,因为标签的内容发生了变化。我将如何让单元格标签在 iOS 9 和 Swift 中以多行显示其所有内容。

最佳答案

你没有指定任何约束(也可能有问题,你需要为整个单元格高度设置明确的约束),但我怀疑问题可能出在

label.numberOfLines = 0

关于ios - UITableViewCell 中的多行标签不适用于 iOS 9 或 Swift 2.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32540030/

相关文章:

ios - Swift:在单 View 应用程序中设置游戏场景

swift - WKWebView 不会加载外部域的网站

Swift - 如何使协议(protocol)既是类又需要采用某种类型

ios - 为什么 Xcode 模拟器 View 与 View 层次结构 View 不同

ios - 为什么重写 tableView( :viewForHeaderInSection:) change the results

ios - Swift,将更多数据加载到 TableView 中会导致滚动滞后

iphone - "EXC_BAD_ACCESS", "-[CFString retain]: message sent to deallocated instance"在表格中滚动时

ios - 堆栈 View 错误还是我错过了什么?

objective-c - 如何在我的 viewController 中显示我的图像,就像下面的屏幕截图一样?

iphone - NSDateFormatter 关闭一小时