1

アプリがクラッシュする理由

[UICollectionViewFlowLayout collectionView:numberOfItemsInSection:]: unrecognized selector sent to instance. 

UICollectionReusableViewこれは、デリゲート メソッドがビュー コントローラーではないmy 内にあるためです。UICollectionView のデリゲートを設定したときにUICollectionView を内部に埋め込み、UICollectionViewSectionHeaderアプリがクラッシュしないようにするにはどうすればよいですか。

#import "HomeBannerReusableView.h"
#import "HomeBannerCell.h"

@interface HomeBannerReusableView () <UICollectionViewDelegate, UICollectionViewDataSource>
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;

@end

@implementation HomeBannerReusableView

- (void)awakeFromNib {
    // Initialization code
    [self.collectionView registerNib:[UINib nibWithNibName:@"HomeBannerCell" bundle:nil] forCellWithReuseIdentifier:@"HomeBannerCell"];
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 1;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    HomeBannerCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeBannerCellReusableView" forIndexPath:indexPath];
    return cell;
}
4

1 に答える 1