已编辑
我正在使用自定义收集单元格加载到collectionview中。但是,当集合视图加载预期的行为时,cellforindex代表将调用3个indexpath,但在这种情况下,仅调用3个第0个indexpath。
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
}
答案 0 :(得分:0)
全部检查