来自 Xib 的 UITableViewCell,单元格高度和单元格选择区域

UITableViewCell from Xib, cell hight and cell selection area

我有一个 UITableViewController,它有一个我想要显示图像和标签的自定义单元格。截图可以很好的说明我的问题,看起来像这样

.

当我 select 任何单元格看起来像

在 tableviewcontroller 中,根据约束,单元格的形状不可见 这是我的带有自动布局约束的自定义单元格

我该如何解决这个问题? ...我在不使用故事板的情况下以编程方式创建了这个 tableviewcontroller。 这是数据源的代码示例和 tableviewcontroller

的代表
override func numberOfSections(in tableView: UITableView) -> Int {
    var numOfSections: Int = 0
    let count = conversations.count
    if count > 0 {
        //  tableView.separatorStyle     = .none
        numOfSections                = 1
        tableView.backgroundView = nil
    }
    else
    {
        let frame                   = CGRect(x: 0,
                                             y: 0,
                                             width: tableView.bounds.size.width,
                                             height: tableView.bounds.size.height)
        let noDataLabel: UILabel    = UILabel(frame: frame)
        noDataLabel.text            = "You don't have any messages. "
        noDataLabel.textColor       = UIColor.black
        noDataLabel.textAlignment   = .center
        tableView.backgroundView    = noDataLabel
        tableView.separatorStyle    = .none
    }
    return numOfSections
}




override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return conversations.count
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCell(withIdentifier: "inboxCell", for: indexPath) as! InboxCell

    cell.conversation = conversations[indexPath.row]

    return cell


}



override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    let uids = conversations[indexPath.row].conversationUseruids
    for uid in uids{

        if uid == Account.account.user.uid{

        }
        else{

            User.getUser(with: uid, completion: { (user) in
                self.selectedUser.append(user!)
            })
        }


    }

    tableView.deselectRow(at: indexPath, animated: true)

    let index = indexPath.row as Int
    messageVC.conversationIndex = index
    messageVC.conversation = self.conversations[index]


    navigationController?.pushViewController(messageVC, animated: true)


}

override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {

    return 80
}

发生这种情况是因为你的图像没有上下约束如果不起作用请告诉我