我有一个使用Dynamic UI的应用程序,我是Apple来调节添加到单元格的UI类型。现在,当添加UI时,该预言是不可编辑的,例如,如果添加了UITEXTFIELD,我将无法添加任何输入或编辑,并且如果添加了datePicker,则无法对其进行编辑。欢迎任何帮助。以下是我的代码的附件
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellModel = elements[indexPath.row]
let cellIdentifier = cellModel.unique_id
// cellModel.type.rawValue
let customCell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier!, for: indexPath) as! CustomElementCell
customCell.configure(withModel: cellModel)
return customCell as! UITableViewCell
}
//我的手机
func configureUI(type: String, placeholder: String) {
let type = TypeView.typeCell(type: type, placeholder: placeholder)
switch type {
case .text:
let tf = DefaultTextField()
tf.placeholder = placeholder
self.contentView.addSubview(tf)
log("THE LOG test")
case .embeddedphoto:
let tf = DefaultTextField()
tf.placeholder = placeholder
tf.keyboardType = .numberPad
log("THE LOG embeddedphoto")
case .formattednumeric:
let tf = DefaultTextField()
tf.placeholder = placeholder
log("THE LOG formattednumeric")
case .datetime:
let dp = UIDatePicker()
self.contentView.addSubview(dp)
log("THE LOG datetime")
}
}
1-您应该为每种动态类型创建一个单元格,然后注册
2-对于当前的实施,您需要在添加的元素中添加约束并清除单元格以避免脱水问题