微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法在Tableview单元格中选择或编辑Textfield

如何解决无法在Tableview单元格中选择或编辑Textfield

我有一个控制器EditProfileController: UITableViewController一个单元格EditProfileCell: UITableViewCell

extension EditProfileController {
    
    override func tableView(_ tableView: UITableView,cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier,for: indexPath) as! EditProfileCell
        cell.delegate = self
        return cell
    }
}

我的EditProfileCell

这是我的TextField:

class EditProfileCell: UITableViewCell {
    lazy var infoTextField: UITextField = {
        let tf = UITextField()
        tf.borderStyle = .none
        tf.font = UIFont.systemFont(ofSize: 14)
        tf.textAlignment = .left
        tf.textColor = .white
        tf.isUserInteractionEnabled = true

        return tf
    }()

}

问题:我可以使用模拟器编辑文本字段的信息。但是当我在iPhone上运行该应用程序时,我什至无法选择文本字段,甚至键盘也不会显示

我已经测试了在扩展名上添加cell.infoTextField.becomeFirstResponder(),并且可以使用,但这仅使最后一个文本字段变为可编辑状态。

我做错了什么?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。