Как определить представление коллекции размеров, когда я использую два разных типа ячеек, и размер одной из этих ячеек всегда один, но размер другой зависит от массива, и из-за этого его размер является динамическим c.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if indexPath.row == 0 {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ProfileCell", for: indexPath) as! ProfileCollectionViewCell
cell.bioLabelText.text = bio
return cell
}else {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! CountryCollectionViewCell
cell.countryLabel.text = city
cell.imgView.image = UIImage(named: "lake.jpg")
cell.makeRounded()
return cell
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return uniqueCountryArray.count
}
мой номер ProfileCell должен быть один, а номер другой ячейки должен быть uniqueCountryArray.count. Однако, когда я пишу «return uniqueCountryArray.count + 1», это выдает мне ошибку. Когда я пишу «return uniqueCountryArray.count», я пропускаю один элемент массива.
Как я могу динамически получить все элементы массива? И размер массива id равен 0, я все равно должен показать, что ячейка исходит из профиля Cell.