iOS8 Swift-动态调整tableview单元格大小的问题

iOS8 Swift-动态调整tableview单元格大小的问题,swift,dynamic,ios8,resize,tableview,Swift,Dynamic,Ios8,Resize,Tableview,您将看到,当字幕文本标签只有一行时,它的大小会正确调整,但当有多行时,它会变得一团糟。我认为这可能与约束有关?现在我正在使用自动布局约束。你可以在截图中看到它们。这是创建我的单元格的代码 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> DealCell { let cell = tableView.dequeueReusableCellW

您将看到,当字幕文本标签只有一行时,它的大小会正确调整,但当有多行时,它会变得一团糟。我认为这可能与约束有关?现在我正在使用自动布局约束。你可以在截图中看到它们。这是创建我的单元格的代码

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> DealCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("Deal Cell", forIndexPath: indexPath) as DealCell

    let currentBar = bars[indexPath.row] as BarAnnotation
    cell.barName.text = currentBar.name
    cell.deal.text = currentBar.deal
    cell.distanceToBar.text = String(format: "%.3f mi", currentBar.distance)

    // Set the height of the table view cells
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    self.tableView.estimatedRowHeight = 44.0;

    return cell
}

有什么想法吗?

在UITableViewDelegate中使用
tableView:heightForRowAtIndexPath:
函数。 使用此选项,可以单独设置每行的高度

有关更多信息:

也可以使用本文中的自动布局设置。

这与创建单元格时设置高度是一样的。我认为我的问题应该被命名为“动态调整大小的单元格上的约束问题”。问题是当标签不止一行时,它没有被正确地约束,如图所示。