Ios 两个不同的集合视图获取另一个集合的项目计数
我有一个应用程序,有两个不同的阵列,通常有两个不同的项目计数。出于某种原因,第一个集合视图正在获取第二个集合视图的项目计数,除非我去掉第二个集合视图 我的代码: 步骤: 1.说你的收藏是Ios 两个不同的集合视图获取另一个集合的项目计数,ios,swift,uicollectionview,Ios,Swift,Uicollectionview,我有一个应用程序,有两个不同的阵列,通常有两个不同的项目计数。出于某种原因,第一个集合视图正在获取第二个集合视图的项目计数,除非我去掉第二个集合视图 我的代码: 步骤: 1.说你的收藏是 var albumsViewCollectionView, songsViewCollectionView : UICollectionView! 为2个CollectionView注册nib文件 您的collectionview数据源方法 func collectionView(_ collection
var albumsViewCollectionView, songsViewCollectionView : UICollectionView!
为2个CollectionView注册nib文件
您的collectionview数据源方法
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if collectionview == albumsViewCollectionView {
return albumCount
}
else if collectionview == songsViewCollectionView {
return songsCount
}
return 0
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if collectionView == albumsViewCollectionView {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "AlbumsViewCollectionView", for: indexPath) as! AlbumsViewCollectionView
return cell
}
else if collectionView == songsViewCollectionView {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "SongsViewCollectionView", for: indexPath) as! SongsViewCollectionView
return cell
}
return UICollectionViewCell()
}
不要发布代码的链接。您的问题并将相关代码复制粘贴到您的问题中。可能未设置songsViewCollectionView,请检查您的IBOutlets,并对其进行调试