iOS-在TableViewCell中并排标记对象

iOS-在TableViewCell中并排标记对象,ios,xcode,swift,uitableview,Ios,Xcode,Swift,Uitableview,我正在创建一个非常简单的动态TableViewCell,最左侧有一个图像,中间有一个标签,最右侧有一个标签,如下所示 我目前正在显示图像和中心标签,但我似乎不知道如何对齐单元格最左侧的第二个标签对象 当我运行应用程序时,它只显示图像和中心标签。 如果有人对如何使第二个标签对象显示与图像和第一个标签对象对齐有任何建议,将不胜感激 TableViewCell: class AttractionTableViewCell: UITableViewCell { @IBOutlet weak var

我正在创建一个非常简单的动态TableViewCell,最左侧有一个图像,中间有一个标签,最右侧有一个标签,如下所示

我目前正在显示图像和中心标签,但我似乎不知道如何对齐单元格最左侧的第二个标签对象

当我运行应用程序时,它只显示图像和中心标签。 如果有人对如何使第二个标签对象显示与图像和第一个标签对象对齐有任何建议,将不胜感激

TableViewCell:

class AttractionTableViewCell: UITableViewCell {

@IBOutlet weak var attractionImage: UIImageView!

@IBOutlet weak var attractionLabel: UILabel!

@IBOutlet weak var attractionTime: UILabel!

override func awakeFromNib() {
    super.awakeFromNib()
    // Initialization code
}

override func setSelected(selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: animated)

    // Configure the view for the selected state
}

}
TableViewController:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell =
    self.tableView.dequeueReusableCellWithIdentifier(
        "AttractionTableCell", forIndexPath: indexPath)
        as! AttractionTableViewCell

    let backgroundImage = UIImage(named: "blued.jpg")
    let imageView = UIImageView(image: backgroundImage)
    self.tableView.backgroundView = imageView
    tableView.tableFooterView = UIView(frame: CGRectZero)
    imageView.contentMode = .ScaleAspectFill


            if (indexPath.section == 0){
        cell.attractionLabel.text = attractionNames[indexPath.row]
        cell.attractionImage.image = UIImage(named: attractionImages[indexPath.row])

    }
    if (indexPath.section == 1){
        cell.attractionLabel.text = attractionNames2[indexPath.row]
        cell.attractionImage.image = UIImage(named: attractionImages2[indexPath.row])

    }
    return cell
}

为图像视图和标签提供约束

必须为视图提供一些约束,以便它们在单元上都可见

为图像提供高度、宽度、前导、顶部约束

在容器中水平居中放置两个UIBLABLE

为标签提供顶部、底部、前导和尾随约束


最后将文本分配给CellForRowatineXpath中的attractionTime标签添加一些自动布局约束

对于图像:

对于中间标签:

对于正确的标签:

结果应该如下所示:


您是如何添加前两个元素的?我们需要看一些代码,看看您使用的约束。实际上,我只是拖放了图像和标签。对于图像,我将宽度和高度设置为相等,然后将视图模式设置为aspect fit。对于我刚才拖放的标签。您显示的布局是一个常规的
UITableViewCell
,样式为
UITableViewCellStyleValue1
…您刚才拖放了吗?没有为标签添加任何约束?不,我不相信有任何约束。文档大纲中未显示任何内容。