@@ -173,6 +173,7 @@ - (void)setUpSegmentControl
173173 NSArray *_segmentItems = @[@" 全部商品" ,@" 可兑换商品" ];
174174 __weak typeof (self) weakSelf = self;
175175 _shopSegmentControl = [[XTSegmentControl alloc ] initWithFrame: CGRectMake (0 , CGRectGetHeight (_collectionHeaderView.frame)- kMySegmentControl_Height - 5 , kScreen_Width , kMySegmentControl_Height ) Items: _segmentItems selectedBlock: ^(NSInteger index) {
176+
176177 [weakSelf segmentControlSelecteIndex: index];
177178 }];
178179 _shopSegmentControl.backgroundColor = [UIColor whiteColor ];
@@ -188,9 +189,6 @@ - (void)segmentControlSelecteIndex:(NSInteger)index
188189 _oldSelectedIndex = index;
189190 _shopObject.shopType = index;
190191 [_collectionView reloadData ];
191- if (_collectionView.contentOffset .y > CGRectGetHeight (_collectionHeaderView.frame ) ) {
192- [_collectionView setContentOffset: CGPointMake (0 , CGRectGetHeight (_collectionHeaderView.frame)) animated: NO ];
193- }
194192}
195193
196194
@@ -220,11 +218,6 @@ - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UIColl
220218 _shopBannerView = [[ShopBannerView alloc ] initWithFrame: CGRectMake (0 , 0 , kScreen_Width , bannerHeight)];
221219 _shopBannerView.curBannerList = shopBannerArray;
222220 [_collectionHeaderView addSubview: _shopBannerView];
223- __weak typeof (self) weakSelf = self;
224- // _shopBannerView.tapActionBlock = ^(ShopBanner *banner){
225- // [NSObject showHudTipStr:banner.title];
226- // [weakSelf bannerClicked:banner.title];
227- // };
228221 [_shopBannerView reloadData ];
229222 _shopSegmentControl.frame = CGRectMake (0 , bannerHeight, kScreen_Width , kMySegmentControl_Height );
230223 height = kMySegmentControl_Height + bannerHeight ;
@@ -255,16 +248,17 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
255248- (void )scrollViewDidScroll : (UIScrollView *)scrollView
256249{
257250 CGFloat offsetY = scrollView.contentOffset .y + scrollView.contentInset .top ;
251+ CGFloat bannerHeight = kScreen_Width * (270.0 /640 );
258252
259- CGFloat _shopSegmentControlY = CGRectGetHeight (_collectionHeaderView.frame ) - kMySegmentControl_Height - 5 ;
260-
261- if (offsetY > CGRectGetHeight (_collectionHeaderView.frame )) {
253+ NSLog ( @" %f%f " ,offsetY, CGRectGetHeight (_collectionHeaderView.frame )) ;
254+
255+ if (offsetY >= CGRectGetHeight (_collectionHeaderView.frame ) - kMySegmentControl_Height ) {
262256
263257 _shopSegmentControl.frame = CGRectMake (0 , 0 , kScreen_Width , kMySegmentControl_Height );
264258 [self .view addSubview: _shopSegmentControl];
265259 }else
266260 {
267- _shopSegmentControl.frame = CGRectMake (0 , _shopSegmentControlY + 5 , kScreen_Width , kMySegmentControl_Height );
261+ _shopSegmentControl.frame = CGRectMake (0 ,bannerHeight , kScreen_Width , kMySegmentControl_Height );
268262 [_collectionHeaderView addSubview: _shopSegmentControl];
269263 }
270264}
0 commit comments