我正在使用CollectionViewWaterfallLayout。在"如何使用"部分,它说
您的收藏视图的委托必须符合 CollectionViewWaterfallLayoutDelegate协议并实现 必需的方法,你需要做的就是返回原来的大小 项:
func collectionView(collectionView: UICollectionView, layout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize
我该怎么办?如何使集合视图的委托符合CollectionViewWaterfallLayoutDelegate协议?
答案 0 :(得分:2)
在主视图控制器中添加CollectionViewWaterfallLayoutDelegate
,这样就像
class SearchPhotosViewController: UIViewController, CollectionViewWaterfallLayoutDelegate,UICollectionViewDataSource {
//inside this call the delegate method to return the size of the item
func collectionView(collectionView: UICollectionView, layout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
return CGSizeMake(300, 300)//return the CGSize for the item you want
}
}
答案 1 :(得分:1)
在声明你的类时,你编写了符合UICollectionViewDelegae的代码。示例代码如下:
class myViewController : UIViewController, UICollectionViewDelegate {
...
}