に準拠している必要があり、私は内部のUITabbarとビューコントローラを使用してCHTCollectionViewWaterfallLayoutを持つサブビューを挿入し、私はランタイムエラーを得ています:UICollectionViewのデリゲートはCHTCollectionViewDelegateWaterfallLayoutプロトコル
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView's delegate should conform to CHTCollectionViewDelegateWaterfallLayout protocol'
私はすでにCHTCollectionViewDelegateWaterfallLayoutを宣言しました実装する必要があります。
解決方法、解決方法はありますか?ここ
私の最初のビューコントローラコード:
#import <UIKit/UIKit.h>
#import "CHTCollectionViewWaterfallLayout.h"
@interface MainViewController : UIViewController <UICollectionViewDataSource, CHTCollectionViewDelegateWaterfallLayout, UICollectionViewDelegate, UICollectionViewDataSourcePrefetching>
@property (strong, nonatomic) IBOutlet UICollectionView *collectionViewController;
@end
との.mファイルにデリゲートの必要な方法:ここ
- (void)viewDidLoad {
[super viewDidLoad];
[self.myTabbar setAlpha:0.95];
self.myTabbar.delegate = self;
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
[self.view insertSubview:[storyBoard instantiateViewControllerWithIdentifier:@"tab1"].view belowSubview:self.myTabbar];
[self.myTabbar setSelectedItem:self.myTabbar.items[0]];
self.currentItem = [self.myTabbar selectedItem];}
とは、コレクションビューの.hファイルを持っているView Controllerの
- (void)viewDidLoad {
[super viewDidLoad];
self.collectionViewController.prefetchDataSource = self;
self.collectionViewController.dataSource = self;
self.collectionViewController.delegate = self;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.item % 2 == 1) {
CGFloat cellWidth = [UIScreen mainScreen].bounds.size.width /2.2;
CGFloat cellHeight = cellWidth * 1.6;
return CGSizeMake(cellWidth, cellHeight);
} else {
CGFloat cellWidth = [UIScreen mainScreen].bounds.size.width /2.2;
CGFloat cellHeight = cellWidth * 2;
return CGSizeMake(cellWidth, cellHeight);
}
}
ありがとうございましたが、問題はまだでも、私は** ** UICollectionViewDelegateを登録するかどうかが起こります。 初期ビューとして** MainViewController **を実行すると正常です。しかし、私が最初のビュー**から実行すると、** - (CGSize)collectionView(UICollectionView *)の後にこの問題が発生します。collectionViewレイアウト:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath **メソッドdone、 ** - [CHTCollectionViewWaterfallLayout prepareLayout]の直後にスタックする –