例如:
@IBOutlet weak var Collection01: UICollectionView!
@IBOutlet weak var Collection02: UICollectionView!
那么如何分别为他们定义Delegate与DataSource的方法呢,例如下面这个返回单元格数量的方法
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 2
}
Use two classes as Delegate and DataSource through Extension, and you can also give a Tag to judge
Write two classes specifically to be used as dataSource. In fact, there are many benefits to extracting the datasource from the controller. . .
@Taku The first half of the sentence is the correct solution. However, the Tag judgment in the second half of the sentence is not good and the efficiency is low.
Let me tell you a simple implementation:
PS: The first letter of the variable name should be lowercase.