Почему-то не могу заставить отображаться текст label для второго CollectionView в одном ViewController. Почему-то для horizontalNumbers label.text ничего не показывает.
Мой код:
class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
@IBOutlet weak var mainNumbers: UICollectionView!
@IBOutlet weak var horizontalNumbers: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
mainNumbers.delegate = self
mainNumbers.dataSource = self
horizontalNumbers.delegate = self
horizontalNumbers.dataSource = self
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if collectionView == mainNumbers {
return 81
} else {
return 5
}
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if collectionView == mainNumbers {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! MainCell
cell.label.text = "f"
cell.backgroundColor = .systemGreen
return cell
} else {
let cell2 = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell2", for: indexPath) as! CellSecond
cell2.label.text = "fds"
cell2.backgroundColor = .systemGreen
return cell2
}
}
}