集合视图一次仅加载一个单元格

问题描述 投票:-1回答:1

已编辑

我正在使用自定义收集单元加载到collectionview中。但是,当集合视图加载预期的行为时,cellforindex委托将调用3索引路径,但在这种情况下仅调用3次第0个索引路径。

let nib = UINib(nibName: "cellName", bundle: nil)
self.collectionvView?.register(nib, forCellWithReuseIdentifier: "cellId")

 func collectionView(_ collectionView: UICollectionView,
              cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
  {
     let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellId",for: indexPath) as! DetailCollectionViewCell
  }
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
{
   return self.arrIds.count
}
swift loading collectionview indexpath
1个回答
0
投票

全部检查

  1. self.arrIds.count = 3
  2. numberOfSections = 1
  3. numberOfItemsInSection
  4. cellForItemAt
© www.soinside.com 2019 - 2024. All rights reserved.