Ошибка в представлении сбора с двумя разными типами ячеек. Ошибка: фатальная ошибка: индекс вне диапазона - PullRequest
0 голосов
/ 06 февраля 2020

в поле зрения load: arrMoreOptions = ["Служба поддержки", "О нас", "Честная игра", "Как играть", "Политика конфиденциальности", "Система очков", "T & C", " FAQ "," Свяжитесь с нами "," Кошелек "]

fun c collectionView (_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {print (section) return self.arrMoreOptions.count}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

    let index : Int = (indexPath.section * 2) + indexPath.row
    print("index\(index)")
    if index % 2 == 0 {
         let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "MoreLeftCollectionViewCell", for: indexPath) as! MoreLeftCollectionViewCell

        //cell.lblSportsName.text = "CHAMPIONSHIP"

        let left = stride(from: 0, to: arrMoreOptions.count, by: 2).map { arrMoreOptions[$0] }

        let name = left[indexPath.row]
       // print("left col\(name)")

        cell.lblMoreOptions.text = name

        return cell
    }

    else{
         let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "MoreRightCollectionViewCell", for: indexPath) as! MoreRightCollectionViewCell
                   //cell.lblSportsName.text = "CHAMPIONSHIP"

            let right = stride(from: 1, to: arrMoreOptions.count, by: 2).map { arrMoreOptions[$0] }

                   let name = right[indexPath.row]
                  // print("right col\(name)")
                   cell.lblMoreOptions.text = name

                   return cell
    }


}

}

...