我在viewController中创建了2个collectionView
SchoolActivitycollectionView = UICollectionView(frame:CGRectMake(0,0,self.view.bounds.width,self.view.bounds.height),collectionViewLayout:flowLayout)
PrivateActivityCollectionView = UICollectionView(frame:CGRectMake(0,0,self.view.bounds.width,self.view.bounds.height),collectionViewLayout:flowLayout)
PrivateActivityCollectionView.delegate = self
PrivateActivityCollectionView.dataSource = self
SchoolActivitycollectionView.delegate = self
SchoolActivitycollectionView.dataSource = self
但问题出在数据源中
func collectionView(collectionView:UICollectionView,numberOfItemsInSection section:Int) - > Int {
if collectionView == SchoolActivitycollectionView { ..
我试图分开这2个集合视图我不能 . 我打印出( collectionView == SchoolActivitycollectionView
)它显示为false .
我也试过 isEaqual()
.
我只是不能分开他们...所以我不能独立设置这2个集合视图...我怎么能设置这2个集合视图?
2 回答
您可以尝试为集合视图提供标记
然后比较一下
以下代码
是错的 .
您应该使用
===
来比较两个引用 .