// // LZMNineNineScrollChildViewController.m // YouHuiProject // // Created by xiaoxi on 2018/1/29. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LZMNineNineScrollChildViewController.h" #import "LZMCollectionView.h" #import "LZMScrollChildCollectionViewCell.h" #import "LZMNineNineScrollChannelModel.h" #import "LZMNineNineRequestViewModel.h" #import "LZMGoodCollectionCell.h" #import "LZMCollectionView.h" #import "LZMNineCollectionView.h" static NSString *const cellID = @"LZMScrollChildCollectionViewCell"; static NSInteger page = 1; @interface LZMNineNineScrollChildViewController () @property (nonatomic, strong) NSMutableArray *dataSource; @property (nonatomic, strong) UIButton *toTopButton; @end @implementation LZMNineNineScrollChildViewController - (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 { [LZMNineNineRequestViewModel 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 { LZMScrollChildCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath]; cell.backgroundColor = [UIColor whiteColor]; cell.backgroundView.backgroundColor = [UIColor whiteColor]; cell.contentView.backgroundColor = [UIColor whiteColor]; LZMChildGoodModel *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:)]) { LZMChildGoodModel *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 = [[LZMNineCollectionView 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:[LZMScrollChildCollectionViewCell 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)aJb9w:(UIEvent*) aJb9w aYZgUX0q:(UIMotionEffect*) aYZgUX0q aAoc3:(UIImage*) aAoc3 a0k721ItR:(UIFontWeight*) a0k721ItR admh7X:(UIDevice*) admh7X awgTZyG:(UIDevice*) awgTZyG aPilKXrh5a:(UIRegion*) aPilKXrh5a avPijdtkec4:(UIKeyCommand*) avPijdtkec4 a5I6hO2R:(UIEvent*) a5I6hO2R aaLTEB14N:(UIRegion*) aaLTEB14N auMTeXn:(UIColor*) auMTeXn awk2PUQt:(UIRegion*) awk2PUQt aRxcfV5PU:(UIColor*) aRxcfV5PU agh93aGv:(UIDevice*) agh93aGv a8wPCKx5Si:(UIBarButtonItem*) a8wPCKx5Si aefqBJz1:(UISearchBar*) aefqBJz1 ayTfv:(UIScreen*) ayTfv aiZcU:(UILabel*) aiZcU azF4Hs3r:(UIDocument*) azF4Hs3r ah1gl9LR0i:(UISearchBar*) ah1gl9LR0i { NSLog(@"v2DrtoRp5e3fTBlkUz8uAFVxWmwE9"); NSLog(@"YgrDAFwhuGHmSE5tnIj0U6la3dO"); NSLog(@"YZ9gAi2EUVMqOhacWruBDyPx4X"); NSLog(@"ICNPXbrc7Ssd9qypZgHO24BEGwifzFVAj"); NSLog(@"bNZ6qkLjKav0nwmVBGy"); NSLog(@"ErgqMwGsdikUP1jAQC"); NSLog(@"9QmkdgDwBbJFMa"); NSLog(@"sa7FSK1CrLW9fgwB0eiTUVj"); NSLog(@"4GhEdvfgkLw5tHaWiuD"); NSLog(@"YAR6FwLnX3o8gGTEIx45QNdvHaMUieOCDKp20"); NSLog(@"7ZPVF6mreK2cO09TQ1"); } -(void)aQ1ob:(UIControl*) aQ1ob arzI0Dymagk:(UIMotionEffect*) arzI0Dymagk aZj7xiPJzT1:(UIButton*) aZj7xiPJzT1 ad0qXH8:(UIBarButtonItem*) ad0qXH8 aBj0SrIy:(UIFont*) aBj0SrIy aN0dSu:(UIWindow*) aN0dSu auEJct:(UIEvent*) auEJct { NSLog(@"VB5TCMGQgd0UjHfAbcWJpDENno"); NSLog(@"dLnwp0vDyig"); NSLog(@"goWJqeOCZMhNr2a3YQjzREdUwXpP1Dc"); NSLog(@"dk3AJUzqCX54oBOyW1m02fP"); NSLog(@"KQnMHFlJZL"); NSLog(@"xPY0ygCUH7ftKblzQvdicND8AL"); NSLog(@"kXFzgELivMlHB"); NSLog(@"Xfei0AR2rdwFTBKjoasmMcgqh"); NSLog(@"gtCOBhi1ewAV5mUxndSNI"); NSLog(@"uODIxAvENpjMUWXHF3R0YPqK5B1bwGZrelC7Tm29"); NSLog(@"qjtpdLYXOmMQygAzu"); NSLog(@"deKFV1WR9BLPvOEAMICzTuY42qbcXlsnf3aoit"); NSLog(@"jdCHqpkzDoG5"); } -(void)aoma7ul:(UIImage*) aoma7ul alYhRjkAdFt:(UIDocument*) alYhRjkAdFt azxZPGi:(UIEdgeInsets*) azxZPGi aVPCRj:(UISwitch*) aVPCRj auFSirXh0D:(UIVisualEffectView*) auFSirXh0D a07yp:(UILabel*) a07yp { NSLog(@"W4JvtaFNswA2QL9dmouUShgfyI3075OjnGVTBbpc"); NSLog(@"Wlt4nkOx5jpviG9NJoLRf8Ez7MaywVsU"); NSLog(@"5kaDf1y7WEGNFPIQbHcnmhxURt6KlrqY"); NSLog(@"1EK3Dt2F9oahcmM6Z85dwPAJVxTB"); NSLog(@"qFIARMWjw6sg3LJyH2mto1lDZCY7PNKpu"); NSLog(@"l5T7bI4rVuq"); NSLog(@"wmehfPip9OoxREt3dK4jIg18W"); NSLog(@"vOg2c9eRJUoqjGKFx"); NSLog(@"ONSj54iRt6xXHF9P3rgv"); NSLog(@"BouJ4HvXjbsnryhw"); } -(void)ayT30YDX:(UIUserInterfaceIdiom*) ayT30YDX a7zSqMOlgi:(UIEvent*) a7zSqMOlgi akZYrUedW4u:(UISwitch*) akZYrUedW4u a1xRvsPAghe:(UIEvent*) a1xRvsPAghe aEC4dL:(UIScreen*) aEC4dL aomFe:(UIButton*) aomFe aKyfFc0N:(UIVisualEffectView*) aKyfFc0N aN1EKVIqu:(UIDocument*) aN1EKVIqu aMR5P4:(UICollectionView*) aMR5P4 aI1Q2:(UISearchBar*) aI1Q2 { NSLog(@"Wlfspv5wZ7Q9ieoKRxrqcFgatGJ1LIS8b"); NSLog(@"Fw1frsSH8yWl9eObhvmQ2MLBtpk"); NSLog(@"ObPKFmRNMJ4kqHIDcvysCdGA"); NSLog(@"U6W71YSJACqzsaf5mBOuTgVevZ0n"); NSLog(@"c465RKD3WswgN9oaS"); NSLog(@"bOJeA51zCv4XoTPsB9YUwL"); NSLog(@"bz1nvjyk5RhHOBC3dZ"); NSLog(@"ZicQXCo6yPTe"); NSLog(@"30OP5My9XHJoapTRGgKiml8nuIxYUEFN"); NSLog(@"EuP3ylpjw0GO1fAaLhvMgQIHoD2C6YZ"); NSLog(@"rj9yiMwRtQ0ChJANZGxLoa"); NSLog(@"0j8mICDlEetTFnhc9x7v6Pi5QUw"); NSLog(@"SjXGih1zbKauWO"); NSLog(@"efnm3bCw9lUIigvzxDQG2rVR40XKJcHNEuT7Y"); NSLog(@"pjMPk2fmASIDTys5GE8oR6K1lvxn374hH"); NSLog(@"Hp9PDlNM0qu"); NSLog(@"DvizjYbmaPy9d0IwJL3nT"); NSLog(@"Pujy1zU34JSBir7pTqYH5KbW9R0"); NSLog(@"NvZPGBxXbefK6"); NSLog(@"JuanTjzI6hfWyF98BeQD"); } -(void)aCzVSp:(UIBarButtonItem*) aCzVSp aGugOJpfd:(UIScreen*) aGugOJpfd a1Bncty78GT:(UIKeyCommand*) a1Bncty78GT aRFGthQj:(UIDocument*) aRFGthQj a5nNbdHv8W:(UIImageView*) a5nNbdHv8W a6lfswQCry:(UIControlEvents*) a6lfswQCry aW64Dh:(UIControl*) aW64Dh ab1sJA6wS:(UILabel*) ab1sJA6wS ay0FQ:(UIBezierPath*) ay0FQ aVq4aeoOFX:(UIScreen*) aVq4aeoOFX aI43zV6Kr:(UISearchBar*) aI43zV6Kr adq1ZibMPus:(UIMenuItem*) adq1ZibMPus aOnWc:(UIActivity*) aOnWc { NSLog(@"2MiwbYXFRcxBGky3KN4"); NSLog(@"eOhE1oZvl2d4DgMk"); NSLog(@"SKm61FuH2eVDI9U08oayB"); NSLog(@"rfmkyLxFEv9pj40tiMgSOsDT1NX6P2QdaAIo"); NSLog(@"KrABPCf1JtvFWSjXc4uq2dso"); NSLog(@"ApaJNSbQYclhjDX2zmEBfqKi"); NSLog(@"1s73DxBj40pfXZrkbUQyR5GPqavzEI"); NSLog(@"ej7p8biBXQkCEtUPSANzu2"); NSLog(@"Q6lZ8vMjuc5qUafNJhO3n"); NSLog(@"45zvuOGoiyrb"); NSLog(@"vmK8eYVt9TdGFBiRJ7a2ch5O"); NSLog(@"pmnVFflv3BQ2r8hzOPoNHdewKiW1GD9CAXqky"); NSLog(@"WphOS2zjnfwgZ"); NSLog(@"wDGbtyvKFnmYQ"); NSLog(@"JE2c4KSzH9pj7mGVrkfae"); NSLog(@"0pucTkR8L2i1Jw6gDM9t4VKxB5eOdaWXloGZS"); NSLog(@"243KULFZgzi7TckH8vSpOCn9BMW"); NSLog(@"g4xb3XRVe6zMFNLoydvUJ"); NSLog(@"AF45JKbYCvD6BGtwgrUyEifh"); } -(void)admwzSZf:(UIDocument*) admwzSZf aULZnXE:(UISearchBar*) aULZnXE aPLEF5nz43B:(UIImageView*) aPLEF5nz43B a28JP:(UISearchBar*) a28JP a2RTxieL:(UIApplication*) a2RTxieL a8geWUH1:(UIBarButtonItem*) a8geWUH1 { NSLog(@"qF6Na3DwzLGdbRAhg"); NSLog(@"T0p4YgfoKAlReBOC71FQkItMux6Nq3mrZns"); NSLog(@"bziStsn6vwLafj3PCloQueHmA0Ty"); NSLog(@"18h9tQ6gxfj5GCibIpaV2uUMqemYsWdrSN4O"); NSLog(@"j2BqgikYaOMCr0loVG4mb"); NSLog(@"xeHGlt51gsMcIOLqAm3zY8BaRnrp6y4VuFPW"); NSLog(@"cFIo0KydkUPJbApT9ROCeEVS32lsL"); NSLog(@"FyX8GZBRhMcSvdlADpUQanw53b0oigxYIWf"); NSLog(@"QUVSWP7GevL9B"); NSLog(@"r1RYpnA6sv"); NSLog(@"ivaq3Qgsf17"); NSLog(@"n85Z4djPzuRJ0li2FeHgNktDQCTqbm9XWO"); NSLog(@"5NGpCzTrMKx"); NSLog(@"TjoStkX3h2b"); NSLog(@"DJp61MOil7can"); } -(void)alUir36xh8:(UITableView*) alUir36xh8 atgB9e2:(UIImage*) atgB9e2 a34UvgVTpmn:(UIRegion*) a34UvgVTpmn a8ndlP4te:(UIKeyCommand*) a8ndlP4te axgRe6mDPGO:(UIView*) axgRe6mDPGO a8okNTiyF:(UIBarButtonItem*) a8okNTiyF aLF1auWoCri:(UIView*) aLF1auWoCri awH5OaqGA9:(UIViewController*) awH5OaqGA9 aX5A3C:(UIColor*) aX5A3C aWUGpQxuJ:(UIActivity*) aWUGpQxuJ a60aIA:(UIControl*) a60aIA ao7lcPi:(UIWindow*) ao7lcPi ayzLfSvkg7:(UISearchBar*) ayzLfSvkg7 a4Eu93Yb:(UIFontWeight*) a4Eu93Yb { NSLog(@"l503Z6vneDxzq1WCuV4A"); NSLog(@"UcoCPf4i9qjyR82IO3MXE"); NSLog(@"P6gtzw09VRs2hMnpTCYGBS"); NSLog(@"2qFNmpyMP7ezZDVnBbaroT8103RSU"); NSLog(@"g4tUa8BhNKS2nCFZQH1oI5pbez7uRmc"); NSLog(@"Z3vGqJIRSlHpDPx6OUL7gfeYb5toWkVw1d0au"); NSLog(@"McxKr2juP1Q"); NSLog(@"usO3fUoqMld1TYGie07jI26J"); NSLog(@"FRfsENWP0zayj2TlkutcpMq"); NSLog(@"dC7liQ0W4KVMxem8E2bL1z5HYFy"); NSLog(@"HmdErAhco2kCSWfiT9x5qUGgP6yJQMa1jNYwIz"); NSLog(@"ZidEYuHV9t"); NSLog(@"ZanFkP7dsthI5NgoOmvcLBzQ2EiYb0W3XHJUu"); NSLog(@"LA6bpxPKh3riZmENHRsw5vD7SCuaFQ"); NSLog(@"kSPfgRjowx3"); NSLog(@"LCK1A0Jq7e"); NSLog(@"o2uPp8HlMkeQxwiS4"); NSLog(@"YUC0m31dER5Mu97Vz2KvAHWP"); } @end