UITableViewCell 视图消失

TableViewCell view disappear

我的 UItableviewCell 中有 UITextField,当我单击键盘上的完成按钮时,我的 Cell 视图已从 Superview 中删除

override func layoutSubviews() {
    super.layoutSubviews()
    self.selectionStyle = .none
    line.backgroundColor = .custom_gray()
    line.snp.makeConstraints { (cons) in
        cons.bottom.left.right.equalTo(phone).inset(0)
        cons.height.equalTo(0.5)
    }
    stack.snp.makeConstraints { (cons) in
        cons.left.right.equalTo(self).inset(25)
        cons.centerY.equalTo(self)
        cons.height.equalTo(230)
        cons.bottom.equalTo(self).inset(15)
    }
    stack.dropShadow()
    stack.layoutIfNeeded()
}

我通过将我的视图添加到 TableviewCell 内容视图

解决了这个问题
 self.contentView.addSubview(stack)
 phone.delegate = self
 password.delegate = self
 stack.snp.makeConstraints { (cons) in
        cons.left.right.equalTo(self.contentView).inset(25)
        cons.centerY.equalTo(self.contentView)
        cons.height.equalTo(230)
        cons.bottom.equalTo(self.contentView).inset(15)
 }
 self.contentView.backgroundColor = .white

我return这个观点来自tableviewHeaderContent

override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        let head = tableView.dequeueReusableCell(withIdentifier: headerid) as! ProfileLoginTableViewCell
        return head.contentView
    }