简体   繁体   English

集合视图的委托符合另一个协议

[英]collection view's delegate conforms to another protocol

I'm using CollectionViewWaterfallLayout . 我正在使用CollectionViewWaterfallLayout In the "How to use" section, it says 在“如何使用”部分中,它说

Your collection view's delegate must conforms to CollectionViewWaterfallLayoutDelegate protocol and implement the required method, all you need to do is return the original size of the item: 您的集合视图的委托必须符合CollectionViewWaterfallLayoutDelegate协议并实现所需的方法,您要做的就是返回项目的原始大小:

func collectionView(collectionView: UICollectionView, layout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize

What should I do here? 我该怎么办? How to make collection view's delegate conform to CollectionViewWaterfallLayoutDelegate protocol ? 如何使集合视图的委托符合CollectionViewWaterfallLayoutDelegate协议?

In your main view controller add CollectionViewWaterfallLayoutDelegate so it will be like 在您的主视图控制器中添加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
    }
}

while declaring your class did you wrote the code to conform to the UICollectionViewDelegae. 在声明您的类时,您是否编写了符合UICollectionViewDelegae的代码。 sample code below : 下面的示例代码:

class myViewController : UIViewController, UICollectionViewDelegate {

...

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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