相关疑难解决方法(0)

自从更新到 xcode 12 以来,我无法在 UITableViewCell 中放置任何 UIControl

我有一个使用 tableview 的搜索表单。今天更新 Xcode 12 后,UISwitch、UITextField、UISlider 在嵌套在 UITableViewCell 中时不再工作。是否有一个属性发生了变化,我需要设置它才能再次工作?

为了确保这不仅仅是我的项目,我创建了一个新项目并在其中放置了一个 UITextField,但它也不起作用。

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = UITableViewCell()
    
    let textField = UITextField(frame: CGRect(x: 5, y: 5, width: 400.0, height: 25.0))
    textField.delegate = self
    textField.backgroundColor = .blue
    cell.addSubview(textField)

    return cell
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    print("this will get called even when selecting the UITextField")
}

func textFieldDidBeginEditing(_ textField: UITextField) {
    print("this is never called")
}
Run Code Online (Sandbox Code Playgroud)

uitableview uicontrol xcode12

8
推荐指数
1
解决办法
1482
查看次数

标签 统计

uicontrol ×1

uitableview ×1

xcode12 ×1