我想在我的UITableView中迭代单元格,其中包含自定义类"tempCell"的单元格,但是,我得到一个错误type of expression is ambiguous without more context
。
let paths = tableView_sign_in.visibleCells()
for cell: tempCell in paths { // type of expression is ambiguous without more context
cell.textfield.enabled = false
}
您必须'if let' customCell
for cell in tableView.visibleCell() {
if let customCell = cell as? TempCell {
customCell.textField.enabled = false
}
}
在迭代时,可以使用可选绑定(if let
)和条件下转换(as?
)将单元格转换为自定义类型:
for cell in tableView.visibleCells() {
if let customCell as? TempCell {
customCell.textField.enabled = false
}
}