【发布时间】:2018-05-29 05:45:43
【问题描述】:
我有一个 Venue 类型的数组(4 项),每个数组都包含一个 imgURLs 字符串的数组(2 项),我在下面收到 ERROR: Index out of range我的collectionViewcellForItemAt 的行。我正在尝试在 tableview 单元格内的 collectionView 中显示每个 Venue 的图像。
let urlString = filteredVenueArray[collectionView.tag].imgURLs[collectionView.tag]
cellForItemAt函数:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "VenueListingCellImage", for: indexPath) as! VenueListingCellImage
let urlString = filteredVenueArray[collectionView.tag].imgURLs[collectionView.tag]
let imgURL = URL(string: urlString)
cell.configureCell(url: imgURL!)
return cell
}
编辑:numberOfItemsInSection 函数
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return filteredVenueArray[collectionView.tag].imgURLs.count
}
【问题讨论】:
-
显示 numberOfItemsInSection 方法代码
-
我已经编辑了我的问题以包含 numberOfItemsInSection 函数。
标签: ios swift uicollectionview