我每个人都有一个水平的CollectionView和TableView
问题:表格视图重复
OpenAllCollapse() {
for (var i = 0; i < this.periods.length; i++) {
this.$refs["period" + i][0].$data.show = true
}
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: OrdersCollectionViewCell.id, for: indexPath) as! OrdersCollectionViewCell
switch indexPath.row{
case 0:
cell.backgroundColor = .red
cell.setupTableview()
cell.tableView.backgroundColor = .red
case 1:
cell.backgroundColor = .green
case 2:
cell.backgroundColor = .blue
case 3:
cell.backgroundColor = .orange
case 4:
cell.backgroundColor = .yellow
default:
break
}
return cell
}
->仅委托和dataSource
答案 0 :(得分:0)
请尝试以下操作:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: OrdersCollectionViewCell.id, for: indexPath) as! OrdersCollectionViewCell
switch indexPath.row{
case 0:
cell.backgroundColor = .red
cell.setupTableview()
cell.tableView.backgroundColor = .red
case 1:
cell.backgroundColor = .green
case 2:
cell.backgroundColor = .blue
case 3:
cell.backgroundColor = .orange
case 4:
cell.backgroundColor = .yellow
default:
break
}
cell.tableView.reloadData()
return cell
}
它可能会帮助您。谢谢。