简体   繁体   中英

How to use two collectionview in one tableview

I have two collectionviews inside tableviewcell. I have set the first one and it works greats. The problem is i dont know how to call second collectionview in datasource protocol functions.

PS i have used ashfurrow`s tutorial for the first one.

In collection view datasource methods, you need to check the collection view reference for which the method is called ,ie,

Example

func collectionView(_ collectionView: UICollectionView, 
numberOfItemsInSection section: Int) -> Int
{
   if collectionView === self.collectionView1
   {
      //code for 1st collection view
   }
   else if collectionView === self.collectionView2
   {
      //code for 2nd collection view
   }
}

Apply same check in other collection view datasource methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM