【发布时间】:2020-07-30 11:37:13
【问题描述】:
编辑
我正在使用自定义集合单元在集合视图中加载。但是当集合视图加载预期行为时 cellforindex 委托将调用 3 个索引路径,但在这种情况下只调用第 0 个索引路径 3 次。
override func viewDidLoad()
{
super.viewDidLoad()
let nib = UINib(nibName: "cellName", bundle: nil)
self.collectionvView?.register(nib, forCellWithReuseIdentifier: "cellId")
}
func numberOfSections(in collectionView: UICollectionView) -> Int
{
return 1
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
{
return 10
}
func collectionView(_ collectionView: UICollectionView,
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
{
print("indexpath.row ----------------- ",indexPath.row)
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellId",for: indexPath) as! DetailCollectionViewCell
return cell
}
【问题讨论】:
-
请提供一些代码
-
发布您的
collectionView(_:numberOfItemsInSection:)方法。 -
提供
cellForRow的完整代码。
标签: swift loading collectionview indexpath