I build a collectionView
inside a tableView
cell,like below picture show:
then drag a
IBOutlet
in Custom UITableViewCell
named ServicePromotionItemCell setting UICollectionViewDataSource
.
main code:
#import "ServicePromotionCollectionView.h"
#import <HexColor.h>
@interface ServicePromotionItemCell ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property (strong, nonatomic) IBOutlet ServicePromotionCollectionView *promotionCollectionView;
@end
@implementation ServicePromotionItemCell
- (void)awakeFromNib {
UICollectionViewFlowLayout* flowLayout = [[UICollectionViewFlowLayout alloc]init];
_promotionCollectionView = [[ServicePromotionCollectionView alloc] initWithFrame:self.bounds collectionViewLayout:flowLayout];
_promotionCollectionView.delegate = self;
_promotionCollectionView.dataSource = self;
[_promotionCollectionView registerClass:ServicePromotionCollectionViewCell.self forCellWithReuseIdentifier:@"ServicePromotionCollectionCell"];
}
#pragma mark - UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return 3;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ServicePromotionCollectionCell" forIndexPath:indexPath];
return cell;
}
}
But when I run app,It seem not init UICollectionView
, does I miss something?
Please help me.Thanks :)