2016-03-24 12 views
0

私は​​を使用しています。 「どのように使用する」のセクションでは、それは、あなたがする必要があるすべては アイテムの元のサイズを返すですコレクションビューのデリゲートが別のプロトコルに準拠しています

あなたのコレクションビューのデリゲートは CollectionViewWaterfallLayoutDelegateプロトコルに準拠し、 必要なメソッドを実装しなければならないと言う:

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

ここで何をすればよいですか?コレクションビューのデリゲートをCollectionViewWaterfallLayoutDelegateプロトコルに準拠させる方法

答えて

1

あなたのクラスを宣言している間に、UICollectionViewDelegaeに準拠するコードを記述しましたか?以下のサンプルコード:のUIViewController、UICollectionViewDataSource、CollectionViewWaterfallLayoutDelegate、UISearchBarDelegate、UICollectionViewDelegateFlowLayout {} `それはなかったの:メインビューコントローラで

class myViewController : UIViewController, UICollectionViewDelegate { 

... 

} 
+0

ようになります仕事はありません。 「タイプSearchPhotosViewControllerがプロトコルCollectionViewWaterfall LayoutDelegateに適合しません」 – luiyezheng

+3

CollectionViewWaterfallLayoutDelegateで説明されているすべての必要なメソッドを実装しましたか? – Ujjwal

2

CollectionViewWaterfallLayoutDelegateを追加するので、私は、クラスSearchPhotosViewController`試み

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 
    } 
} 
関連する問題