繁体   English   中英

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

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

我正在使用CollectionViewWaterfallLayout 在“如何使用”部分中,它说

您的集合视图的委托必须符合CollectionViewWaterfallLayoutDelegate协议并实现所需的方法,您要做的就是返回项目的原始大小:

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

我该怎么办? 如何使集合视图的委托符合CollectionViewWaterfallLayoutDelegate协议?

在您的主视图控制器中添加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
    }
}

在声明您的类时,您是否编写了符合UICollectionViewDelegae的代码。 下面的示例代码:

class myViewController : UIViewController, UICollectionViewDelegate {

...

}

暂无
暂无

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

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