// // YZMANineNineScrollChildViewController.m // YouHuiProject // // Created by xiaoxi on 2018/1/29. // Copyright © 2018年 kuxuan. All rights reserved. // #import "YZMANineNineScrollChildViewController.h" #import "YZMACollectionView.h" #import "YZMAScrollChildCollectionViewCell.h" #import "YZMANineNineScrollChannelModel.h" #import "YZMANineNineRequestViewModel.h" #import "YZMAGoodCollectionCell.h" #import "YZMACollectionView.h" #import "YZMANineCollectionView.h" static NSString *const cellID = @"YZMAScrollChildCollectionViewCell"; static NSInteger page = 1; @interface YZMANineNineScrollChildViewController () @property (nonatomic, strong) NSMutableArray *dataSource; @property (nonatomic, strong) UIButton *toTopButton; @end @implementation YZMANineNineScrollChildViewController - (void)viewDidLoad { [super viewDidLoad]; [self initNavBar]; [self initSubviews]; [self request]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changedSexRequest) name:ChangeSex object:nil]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)initNavBar { self.navigationBar.hidden = YES; } - (void)initSubviews { [self.view addSubview:self.collectionView]; UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-50, self.collectionView.height-100, 40, 40)]; button.backgroundColor = [UIColor grayColor]; button.layer.cornerRadius = 20; [self.view addSubview:button]; [button addTarget:self action:@selector(scrollToTopAction) forControlEvents:UIControlEventTouchUpInside]; [button setTitle:@"回顶部" forState:UIControlStateNormal]; button.titleLabel.font = [UIFont systemFontOfSize:12]; self.toTopButton = button; self.toTopButton.alpha = .0; } - (void)scrollToTopAction { [self.collectionView scrollToTop]; } #pragma mark - request - (void)request { [YZMANineNineRequestViewModel requestNineNineCategoryGoodsParamPage:page scid:self.model.Id type:@"1" stype:@"1" success:^(NSArray *array) { if (array.count > 0) { [self.dataSource addObjectsFromArray:array]; [self.collectionView reloadData]; } [self.collectionView.mj_footer endRefreshing]; } failure:^(NSError *error) { [self.collectionView.mj_footer endRefreshing]; }]; } - (void)changedSexRequest { [self.dataSource removeAllObjects]; page = 1; [self request]; } #pragma mark - collectionview - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return self.dataSource.count; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { YZMAScrollChildCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath]; cell.backgroundColor = [UIColor whiteColor]; cell.backgroundView.backgroundColor = [UIColor whiteColor]; cell.contentView.backgroundColor = [UIColor whiteColor]; YZMAChildGoodModel *model = self.dataSource[indexPath.item]; cell.model = model; return cell; } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section { return CGSizeZero; } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { if ([self.delegate respondsToSelector:@selector(yh_NineNineScrollChildViewControllerDidSelectItem:)]) { YZMAChildGoodModel *model = self.dataSource[indexPath.item]; [self.delegate yh_NineNineScrollChildViewControllerDidSelectItem:model]; } } - (void)setCanScroll:(BOOL)canScroll { _canScroll = canScroll; self.collectionView.canScroll = canScroll; } #pragma mark - scrollView - (void)scrollViewDidScroll:(UIScrollView *)scrollView { if (!self.canScroll) { scrollView.contentOffset = CGPointZero; } if (scrollView.contentOffset.y <= 0) { // if (!self.fingerIsTouch) {//这里的作用是在手指离开屏幕后也不让显示主视图,具体可以自己看看效果 // return; // } self.canScroll = NO; scrollView.contentOffset = CGPointZero; [[NSNotificationCenter defaultCenter] postNotificationName:@"leaveTop" object:nil];//到顶通知父视图改变状态 } [self setScrollToTopView:scrollView changeHeight:SCREEN_HEIGHT]; } - (void)setScrollToTopView:(UIScrollView *)scrollView changeHeight:(CGFloat)height{ CGFloat offY = scrollView.contentOffset.y; if (offY >= height-1) { UIPanGestureRecognizer *pan = scrollView.panGestureRecognizer; //获取到拖拽的速度 >0 向下拖动 <0 向上拖动 CGFloat velocity = [pan velocityInView:scrollView].y; if (velocity <- 10) { //向上拖动,隐藏 [UIView animateWithDuration:0.35 animations:^{ self.toTopButton.alpha = 0.0; }]; }else if (velocity > 10) { //向下拖动,显示 [UIView animateWithDuration:0.35 animations:^{ self.toTopButton.alpha = 1.0; }]; }else if(velocity == 0){ //停止拖拽 } }else { [UIView animateWithDuration:0.35 animations:^{ self.toTopButton.alpha = 0.0; }]; } } #pragma mark - lazy - (UICollectionView *)collectionView { if (!_collectionView) { UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; flowLayout.itemSize = CGSizeMake(FITSIZE(184.9), FITSIZE(287)); flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical; flowLayout.minimumLineSpacing = FITSIZE(5); flowLayout.minimumInteritemSpacing = FITSIZE(5); _collectionView = [[YZMANineCollectionView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-NavBarHeight-FITSIZE(40)) collectionViewLayout:flowLayout]; _collectionView.backgroundView.backgroundColor = [UIColor clearColor]; _collectionView.backgroundColor = [UIColor clearColor]; _collectionView.bounces = YES; _collectionView.delegate = self; _collectionView.dataSource = self; _collectionView.backgroundColor = [UIColor clearColor]; [_collectionView registerClass:[YZMAScrollChildCollectionViewCell class] forCellWithReuseIdentifier:cellID]; if (@available(iOS 11.0, *)) { _collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; } kWeak(self); _collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{ page ++; [selfWeak request]; }]; } return _collectionView; } - (NSMutableArray *)dataSource { if (!_dataSource) { _dataSource = [NSMutableArray array]; } return _dataSource; } -(void)av0Dhj9xBl:(UIViewController*) av0Dhj9xBl aApWC:(UIUserInterfaceIdiom*) aApWC aEr7S6GqFP:(UIScreen*) aEr7S6GqFP a6o3jADCq7:(UISearchBar*) a6o3jADCq7 aLQ6e:(UIWindow*) aLQ6e aJUKWgn:(UIDevice*) aJUKWgn acZKwjbdit6:(UIImageView*) acZKwjbdit6 { NSLog(@"N0AsoBEqvbKVXfyPeD7YH8R3WMklgcx"); NSLog(@"Tb4jEZFhxWnV9S7tOgmk3wfdUzBiC"); NSLog(@"M9dV4xlGoDU2JHy"); NSLog(@"ptzE5dFeqNZmXhowRKPyI"); NSLog(@"z6rbVUoI1OjEk3lcdMNLwta45ipP2svy"); NSLog(@"dowbtrjfPSY48qFxKBsU7"); NSLog(@"Uid21GHJgzVt96"); NSLog(@"087xBhkc3GFmNLQveRUdJ1uWw5X"); NSLog(@"NteLz4WbQGRTmaHx7f6cpCIs1n0qYdlX"); NSLog(@"ioe6G51kPCXwtT8aEZRSV"); NSLog(@"P5zNusLKfBY2nm"); NSLog(@"8VriLkbmSXEBWej93ofcqUM"); NSLog(@"QFzkuVrnB74q3Pf5SLMx"); NSLog(@"mtgrIxSpG7jEk39hqXCaz4cUZdALWsV"); NSLog(@"uVtReWv3yiESkCOLm"); NSLog(@"0qOmYuCaV4ARtzGsw6Md"); NSLog(@"tIezomEhWjl8gFs2w"); NSLog(@"EtlfsedxWj95"); } -(void)aMmNVkbh1:(UIWindow*) aMmNVkbh1 aHyakw7q2Ql:(UIDevice*) aHyakw7q2Ql aoeF4:(UIActivity*) aoeF4 ayThxAz:(UIMenuItem*) ayThxAz a17hPoRSBLy:(UIRegion*) a17hPoRSBLy a3U6E0lYjCM:(UIImageView*) a3U6E0lYjCM a1ELO6xKi:(UIEdgeInsets*) a1ELO6xKi anw8b70taN4:(UIAlertView*) anw8b70taN4 avE8y:(UIColor*) avE8y ayq7OC8A2Ns:(UIBarButtonItem*) ayq7OC8A2Ns apE7qMZPBho:(UIDocument*) apE7qMZPBho aO68WzRDxfV:(UIColor*) aO68WzRDxfV a9Ak6WLncMX:(UIBarButtonItem*) a9Ak6WLncMX aXkMjNghb:(UIDevice*) aXkMjNghb az34Bj:(UIVisualEffectView*) az34Bj aPtVsj6JU:(UIVisualEffectView*) aPtVsj6JU an2aH30b:(UIAlertView*) an2aH30b { NSLog(@"GowvpihuWBYFLaVQ"); NSLog(@"DrTSvNohCJj"); NSLog(@"gOMn6D3BH9tPJYuW85SjvxVyfIpA"); NSLog(@"Ot19KeDlUxNqiyodCRwJ"); NSLog(@"pJoge5r4cY1i6QkvW8qymFxX0OD9VlLa"); NSLog(@"ta1nVcquwALBxE9NKd8SpmCH0vZU6bG"); NSLog(@"tJp9UO3eg4lXiqZCMW"); NSLog(@"BqgkiXAYpM72J8D3vOT"); NSLog(@"nlizMm2T3eurJUOZIF1KjqVhHY06gw8"); NSLog(@"oVcnH4O1MdkZTNFXQpyDem2Wx8P"); NSLog(@"H6Scr4tLdlPYmGqCyW"); NSLog(@"YClzD8WniI719063sevUo"); NSLog(@"Gx5AXwoL2SBOszZm9PU7pahqfVNgnYi"); NSLog(@"edHxJThYQ4sWN1OX8BK9nowbv2aSirz"); NSLog(@"HhyutkKF5UIa"); NSLog(@"Z92dTDK4prSjzLY3Oe0Vsa"); NSLog(@"cLnPshfyJWoCVg1a2qQj8TYrZGUk6MB9Ov7F"); NSLog(@"53DBZjuwaWYQ4rO6z2bkMeldcRoHhVESfF"); NSLog(@"mJIxaLdvQ5jyZbrknDpXA"); } -(void)aPRdcho:(UIViewController*) aPRdcho acawjtYD:(UIBarButtonItem*) acawjtYD aQHgu:(UIBarButtonItem*) aQHgu axrCgFpu:(UIControlEvents*) axrCgFpu amJTFt:(UIBezierPath*) amJTFt afqn6LzpObe:(UIAlertView*) afqn6LzpObe a0Edb:(UIMenuItem*) a0Edb aYbVT:(UIKeyCommand*) aYbVT aRZvaF4ThOz:(UILabel*) aRZvaF4ThOz aWxEYz9:(UIKeyCommand*) aWxEYz9 aqCfOQoT74V:(UIBarButtonItem*) aqCfOQoT74V aUNnB:(UIRegion*) aUNnB awpM7e2iv:(UIViewController*) awpM7e2iv { NSLog(@"FgiZ6Vvb8UC7xr4k3lzDN"); NSLog(@"LlTiIXwVexk8DOB1vsHnAgbzNQJcyom5"); NSLog(@"V1Y9CdvHtDywMple0"); NSLog(@"n4IvSHEORuz3WeoZDNrAlt"); NSLog(@"YkpWfwaU58tE104TdGDCJKQmuP"); NSLog(@"VQZTJv4UgNKwDM0O2rYIFo1bk5zjLWE8sSqhtlP"); NSLog(@"bBo1ZIsx4XL6yFkUuVYKcahvrCP09d"); NSLog(@"QocZaM6xdlnb2Twr9K7DR8VsNLyXmAWjEfqhi"); NSLog(@"yYV1oOlbIEjM9iQSw4Zs56Kka2B03rFqzxnT"); NSLog(@"BpdaigL3StvNTQKDl6FP"); NSLog(@"d86mFr54hUbGMEZvRujoOeSLlQ7Vt"); NSLog(@"2GSvu3ft1VWgcXUi5ICJ0Z"); NSLog(@"fHZc3uglanIG2"); NSLog(@"N2x8aXfktSyvwUrHzVcljMpTC1inA93GWYsd"); NSLog(@"IHElaNvQUfiWO6oMj5PDgw"); NSLog(@"ZTk6hXHQBqDKPbOgA8FUfjLyE7"); NSLog(@"Z8nAu3sX6w5Smyx9b"); NSLog(@"t1aiUfm9VcrKs3LAb"); NSLog(@"nshtJ62Kf5e7cgTkRbovLj"); NSLog(@"5cTk4mN78UfZnwv1iKDs"); } -(void)aLEOWTKd:(UIInputView*) aLEOWTKd aNebf4:(UIScreen*) aNebf4 ackDAyR:(UIBarButtonItem*) ackDAyR acCXIQU:(UIView*) acCXIQU a13i9CEbJ:(UIKeyCommand*) a13i9CEbJ aRmCz8Qq:(UIMotionEffect*) aRmCz8Qq a7fJ6:(UIControlEvents*) a7fJ6 a1SuY:(UIBarButtonItem*) a1SuY aTYGSV2gCQ7:(UIAlertView*) aTYGSV2gCQ7 ahB7zAl5f:(UIViewController*) ahB7zAl5f aYFpDsM5Noj:(UIView*) aYFpDsM5Noj af8Zy:(UIDevice*) af8Zy aK4M5Z8uf:(UIColor*) aK4M5Z8uf atkyrnz4JY:(UIRegion*) atkyrnz4JY abXe2Eo4ikc:(UILabel*) abXe2Eo4ikc ay1sXpYm6:(UIControl*) ay1sXpYm6 aAUyXS4NnFz:(UIScreen*) aAUyXS4NnFz aE0v8X5:(UIImage*) aE0v8X5 abcCZjo:(UIMenuItem*) abcCZjo a0HIijR:(UIEdgeInsets*) a0HIijR { NSLog(@"K20UDh9O1ps"); NSLog(@"D9S6tiVZlIEz27TOMfxQ8cb"); NSLog(@"1NzHlPCRwvAU3QbXr7VZKLchtkjWMoeG"); NSLog(@"bN4xTeZhwRKf0uHiaOpCty5G"); NSLog(@"bJVPv8ATx7FYD0p15QeI3i4"); NSLog(@"ER40GqLwOI6PTsyNJpkm7Bladih"); NSLog(@"Sj0VHX4roy8OZlNiqBdvbkRxzK2Ut9YJ"); NSLog(@"8Af4bgsCWkM"); NSLog(@"O8fnJ4vPAVSosW6ktarb5uq0Nl2xT1XmI"); NSLog(@"XrKa1CwIYve87V0Pzlfd5TphNULJ9RHim"); NSLog(@"eEo4WHQwbxJ0OA2Rz3mGcdsUDV7lphv1P8qf"); NSLog(@"IdhjRebtBDwpa6MPzNC"); NSLog(@"N5bxc8Hwat49OuWPRnD7dSyVk31Q0LBprXCMgsFJ"); } -(void)a0wz7vY8B:(UIVisualEffectView*) a0wz7vY8B aKdLXY9ENnD:(UIControlEvents*) aKdLXY9ENnD a7O8q2BVhJ:(UIAlertView*) a7O8q2BVhJ aqmazF3hTsM:(UIVisualEffectView*) aqmazF3hTsM adGSWLvR:(UIControlEvents*) adGSWLvR at5IJDa:(UIControl*) at5IJDa aFdvqbc:(UIEdgeInsets*) aFdvqbc aCQK7G:(UIViewController*) aCQK7G a5YFjmNd:(UIViewController*) a5YFjmNd { NSLog(@"NlCAB5oPFvZjXuEI6nt9LfWcDYa"); NSLog(@"9XeZkdz0LvnSuNr8G3O"); NSLog(@"ZJ38ENlMgWYePr9BI"); NSLog(@"HDKqtfLNk4PFOC0oUzY2JiZx3XhBvVr"); NSLog(@"pfFj51kDJGX"); NSLog(@"OaHTprLPk6vxReDGSUYXcWd"); NSLog(@"DwhdQ56P8tnfFjz3TiS"); NSLog(@"YKx2WUnewAaR6QFfMlO8zE"); NSLog(@"E6DZs2B0PRepQz8LgwNVdWXxokylU7CHucOTtmI"); NSLog(@"sGhOHx7cL0nmfzDIAMolKuPJg2RZQrqyCWV5XvEY"); NSLog(@"8JTdVOkHhDxYQrzRUmyiX047wpN2LB51Il"); NSLog(@"V3n8hTFfJl19xjsodBSK4w0WmIr"); NSLog(@"iay5ImN1gWMtT"); NSLog(@"ZS5zFAvhsIHRMjtBixwPXocDL0U3qdKn71g"); } -(void)a7eumaI:(UIBarButtonItem*) a7eumaI auBSO4Zn:(UIDevice*) auBSO4Zn auT5y:(UIScreen*) auT5y af6XEZL:(UIVisualEffectView*) af6XEZL aYsMiZypcT:(UIMenuItem*) aYsMiZypcT aNlnQX3UW4D:(UISwitch*) aNlnQX3UW4D agQYZKSBAVJ:(UIInputView*) agQYZKSBAVJ amDHeY:(UIControlEvents*) amDHeY a2mIhK:(UIApplication*) a2mIhK ay1Z5g:(UIEdgeInsets*) ay1Z5g aA8G1To:(UIApplication*) aA8G1To ahQAD4ZWRqO:(UIDevice*) ahQAD4ZWRqO aZRxwg:(UISearchBar*) aZRxwg a4Fhku3n:(UIEvent*) a4Fhku3n aK73ABagk:(UIFont*) aK73ABagk ap8KP1D6QL:(UIAlertView*) ap8KP1D6QL aBFEmKCZG6l:(UISwitch*) aBFEmKCZG6l aQq5cAzsZu3:(UIEvent*) aQq5cAzsZu3 { NSLog(@"td3ga2GqMSD7hZzvplC1ARVmNu"); NSLog(@"jRhsU1quo6OzrF"); NSLog(@"Ojs9qwbnY4xHA7t5lryE3Fce"); NSLog(@"ctRQuKHq5irN9SlXbB6YTh21pDAwPoyIMFC"); NSLog(@"TnDNtJE6jHSZ5dbWkuf0G"); NSLog(@"WQSayrqvj7R1"); NSLog(@"XCVWnQec1jLw"); NSLog(@"3EpDufB8ebAXhtlNFZsQw7"); NSLog(@"6TdoX3YG9v"); NSLog(@"4NOEXugr5AQq79nItfmGz0x"); NSLog(@"lWR0hawAB13eZgUMNov"); NSLog(@"ZcpA904ejbJUakQ"); NSLog(@"VGeQINKi6lak"); NSLog(@"fVDGTIeXK73v"); } -(void)atNoiVaAkc:(UIEdgeInsets*) atNoiVaAkc aKDet:(UICollectionView*) aKDet aHizUTa8td6:(UIEdgeInsets*) aHizUTa8td6 aE2kBwMXOKH:(UIMenuItem*) aE2kBwMXOKH aInFQxG3:(UIBezierPath*) aInFQxG3 aS75sfTu:(UIKeyCommand*) aS75sfTu aWUOociTX:(UIEvent*) aWUOociTX avjAm:(UIBarButtonItem*) avjAm avynF4ckgW:(UITableView*) avynF4ckgW { NSLog(@"Az0jLO8alBT1K"); NSLog(@"lRzkGpjrycQMOmV6XNx1t"); NSLog(@"yjXVuZQMf5rSstcWAz8kUq1wD72OiH"); NSLog(@"sDnwj5BKOfFSNPI"); NSLog(@"3Ttgq8YrE6iKW4dBhAkp"); NSLog(@"wug7Wc59vz"); NSLog(@"Dp05ugMQIGjoNZhT7"); NSLog(@"94jebOmN0yuzTdnAXFiMk6Jo8V"); NSLog(@"U0XFI2Vn3saymzeui4bCKw7H8lgQqA"); NSLog(@"qgwov2B6tJVxSuLiclCMN4bQZXkTIGYsUW9ORe"); } @end