【发布时间】:2020-09-05 11:58:36
【问题描述】:
我有一个tableview,我创建了cell.xib。
在这些tableview 中会有不同的cells,我对xib 做同样的事情。
我如何使用它的一个例子。
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell( withIdentifier: TableViewCellOne.identifier,
for: indexPath) as? TableViewCellOne
return cell ?? UITableViewCell()
}
if indexPath.row == 1 {
let cell = tableView.dequeueReusableCell( withIdentifier: TableViewCellTwo.identifier,
for: indexPath) as? TableViewCellTWo
return cell ?? UITableViewCell()
}
return UITableViewCell()
}
但我不喜欢这种方法。我如何使用case 做到这一点?
【问题讨论】:
标签: ios swift uitableview uiview uicollectionview