diff --git a/xplan-ios/Main/Home/View/XPPartyHeaderView.m b/xplan-ios/Main/Home/View/XPPartyHeaderView.m index 5a7bdecc..6840f16f 100644 --- a/xplan-ios/Main/Home/View/XPPartyHeaderView.m +++ b/xplan-ios/Main/Home/View/XPPartyHeaderView.m @@ -14,7 +14,7 @@ #import "XPMacro.h" #import "NSArray+Safe.h" -@interface XPPartyHeaderView() +@interface XPPartyHeaderView() /// 背景 @property (nonatomic, strong) UIView *bgView; /// 轮播图 diff --git a/xplan-ios/Main/Monents/View/XPMomentTopicHeaderView.m b/xplan-ios/Main/Monents/View/XPMomentTopicHeaderView.m index 56571fe5..e91da632 100644 --- a/xplan-ios/Main/Monents/View/XPMomentTopicHeaderView.m +++ b/xplan-ios/Main/Monents/View/XPMomentTopicHeaderView.m @@ -10,14 +10,15 @@ #import #import "XPMacro.h" #import "NSArray+Safe.h" +#import ///View #import "XPMomentTopicHeaderCell.h" -@interface XPMomentTopicHeaderView() +@interface XPMomentTopicHeaderView() /// 背景 @property (nonatomic, strong) UIView *bgView; -/// 列表 -@property (nonatomic, strong) UICollectionView *collectionView; +/// 轮播图 +@property (nonatomic, strong) SDCycleScrollView *cycleScrollView; @end @@ -35,7 +36,7 @@ #pragma mark - Private Method - (void)initSubViews { [self addSubview:self.bgView]; - [self.bgView addSubview:self.collectionView]; + [self.bgView addSubview:self.cycleScrollView]; } - (void)initSubViewConstraints { @@ -45,7 +46,7 @@ make.right.mas_equalTo(-15); make.bottom.mas_equalTo(-10); }]; - [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) { + [self.cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.right.bottom.mas_equalTo(0); }]; } @@ -56,6 +57,23 @@ return height+20; } +- (Class)customCollectionViewCellClassForCycleScrollView:(SDCycleScrollView *)view { + return [XPMomentTopicHeaderCell class]; +} + +- (void)setupCustomCell:(UICollectionViewCell *)cell forIndex:(NSInteger)index cycleScrollView:(SDCycleScrollView *)view { + XPMomentTopicHeaderCell *topicCell = (XPMomentTopicHeaderCell *)cell; + MonentsTopicModel *model = [self.topicList safeObjectAtIndex1:index]; + topicCell.topicModel = model; +} + +- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index { + if (self.delegate && [self.delegate respondsToSelector:@selector(momentTopicHeaderViewClickTopic:)]) { + MonentsTopicModel *topicModel = [self.topicList safeObjectAtIndex1:index]; + [self.delegate momentTopicHeaderViewClickTopic:topicModel]; + } +} + #pragma mark - UICollectionViewDelegate - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { @@ -80,7 +98,12 @@ - (void)setTopicList:(NSArray *)topicList { _topicList = topicList; - [self.collectionView reloadData]; + NSMutableArray *tempArr = [NSMutableArray array]; + for (int i = 0; i