【发布时间】:2019-12-23 05:42:04
【问题描述】:
当我想在集合视图中快速查看一个数组时,它会乘以集合视图中的部分数量。为什么会这样,我该如何阻止它?
let numbers = ["one", "two", "three"]
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 3;
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let theCell = collectionView.dequeueReusableCell(withReuseIdentifier: "theCell", for: indexPath) as! cell
for number in numbers {
print("\(number)")
}
return theCell
}
我希望它会回来:
一个
两个
三个
但它却返回了:
一个
两个
三个
一个
两个
三个
一个
两个
三个
【问题讨论】:
标签: ios arrays swift uicollectionview