Commit 90108bd08ef751e6bdc0e96114557f9331f19271
1 parent
c0efbe6f
no message
Showing
11 changed files
with
192 additions
and
179 deletions
CNLiveVideoClassifyKit/Classes/Controller/CNCategoryBaseViewController.h
| ... | ... | @@ -10,12 +10,17 @@ |
| 10 | 10 | |
| 11 | 11 | NS_ASSUME_NONNULL_BEGIN |
| 12 | 12 | |
| 13 | -@interface CNCategoryBaseViewController : CNLiveBaseViewController<JXCategoryListContainerViewDelegate,JXCategoryViewDelegate> | |
| 14 | -@property (nonatomic, strong) NSMutableArray *titles; | |
| 13 | +@interface CNCategoryBaseViewController : CNLiveBaseViewController<JXCategoryViewDelegate,UIPageViewControllerDelegate,UIPageViewControllerDataSource> | |
| 14 | + | |
| 15 | 15 | @property (nonatomic, strong) JXCategoryBaseView *categoryView; |
| 16 | -@property (nonatomic, strong) JXCategoryListContainerView *listContainerView; | |
| 17 | -@property (nonatomic, assign) BOOL isNeedIndicatorPositionChangeItem; | |
| 16 | +@property (nonatomic, strong) UIPageViewController *pageViewController; | |
| 17 | +@property (nonatomic, strong) UIScrollView *findScrollView; | |
| 18 | +@property (nonatomic, strong) NSMutableArray *titles; | |
| 19 | +@property (nonatomic, strong) NSMutableArray *controllersArr;/// 控制器数组 | |
| 20 | + | |
| 21 | +@property (nonatomic, assign) NSInteger ld_currentIndex; //当前选中 | |
| 18 | 22 | |
| 23 | +-(void)addTheFirstPage; //默认页 | |
| 19 | 24 | -(JXCategoryBaseView *)preferredCategoryView; |
| 20 | 25 | -(CGFloat)preferredCategoryViewHeight; |
| 21 | 26 | @end | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/CNCategoryBaseViewController.m
| ... | ... | @@ -6,22 +6,21 @@ |
| 6 | 6 | // 分类控制器根类 |
| 7 | 7 | |
| 8 | 8 | #import "CNCategoryBaseViewController.h" |
| 9 | -#import "CNLiveListManager.h" | |
| 10 | - | |
| 11 | 9 | |
| 12 | 10 | @interface CNCategoryBaseViewController () |
| 13 | - | |
| 14 | 11 | @end |
| 15 | 12 | |
| 16 | 13 | @implementation CNCategoryBaseViewController |
| 17 | 14 | |
| 18 | 15 | - (void)viewDidLoad { |
| 19 | 16 | [super viewDidLoad]; |
| 20 | - | |
| 17 | + self.navigationController.navigationBarHidden = YES; | |
| 21 | 18 | [self.view addSubview: self.categoryView]; |
| 22 | - [self.view addSubview:self.listContainerView]; | |
| 19 | + [self addChildViewController:self.pageViewController]; | |
| 20 | + [self.view addSubview:self.pageViewController.view]; | |
| 23 | 21 | self.view.backgroundColor = [UIColor whiteColor]; |
| 24 | 22 | self.navigationHidden = YES; |
| 23 | + | |
| 25 | 24 | // Do any additional setup after loading the view. |
| 26 | 25 | } |
| 27 | 26 | |
| ... | ... | @@ -30,17 +29,23 @@ |
| 30 | 29 | [super viewDidLayoutSubviews]; |
| 31 | 30 | |
| 32 | 31 | self.categoryView.frame = CGRectMake(0, kStatusHeight, self.view.bounds.size.width, [self preferredCategoryViewHeight]); |
| 33 | - self.listContainerView.frame = CGRectMake(0, [self preferredCategoryViewHeight] +kStatusHeight, self.view.bounds.size.width, self.view.bounds.size.height - [self preferredCategoryViewHeight]-kStatusHeight); | |
| 34 | 32 | } |
| 35 | 33 | -(void)viewWillAppear:(BOOL)animated |
| 36 | 34 | { |
| 37 | 35 | [super viewWillAppear:animated]; |
| 38 | - self.navigationController.interactivePopGestureRecognizer.enabled = YES; | |
| 36 | + self.navigationController.interactivePopGestureRecognizer.enabled = NO; | |
| 39 | 37 | self.navigationHidden = YES; |
| 40 | 38 | |
| 41 | 39 | } |
| 42 | 40 | |
| 43 | 41 | #pragma mark - Public |
| 42 | +-(void)addTheFirstPage{ | |
| 43 | + UIViewController *vc = self.controllersArr[self.ld_currentIndex]; | |
| 44 | + [self.pageViewController setViewControllers:@[vc] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:nil]; | |
| 45 | +} | |
| 46 | +- (void)configCategoryViewWithType:(JXCategoryTitleImageType)imageType selectIndex:(NSInteger)index unselectIndex:(NSInteger)unIndex{ | |
| 47 | + | |
| 48 | +} | |
| 44 | 49 | -(JXCategoryBaseView *)preferredCategoryView{ |
| 45 | 50 | return [[JXCategoryBaseView alloc] init]; |
| 46 | 51 | } |
| ... | ... | @@ -49,23 +54,58 @@ |
| 49 | 54 | { |
| 50 | 55 | return 50; |
| 51 | 56 | } |
| 57 | + | |
| 58 | +#pragma mark - UIPageViewControllerDataSource | |
| 59 | +/// 展示上一页 | |
| 60 | +- (nullable UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController { | |
| 61 | + NSInteger index = self.ld_currentIndex; | |
| 62 | + if (index == 0 || (index == NSNotFound)) { | |
| 63 | + return nil; | |
| 64 | + } | |
| 65 | + index--; | |
| 66 | + self.ld_currentIndex = index; | |
| 67 | +// [self.categoryView.delegate categoryView:self.categoryView didSelectedItemAtIndex:self.ld_currentIndex]; | |
| 68 | + return [self.controllersArr objectAtIndex:index]; | |
| 69 | +} | |
| 70 | +/// 展示下一页 | |
| 71 | +- (nullable UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController { | |
| 72 | + NSInteger index = self.ld_currentIndex; | |
| 73 | + if (index == self.controllersArr.count - 1 || (index == NSNotFound)) { | |
| 74 | + return nil; | |
| 75 | + } | |
| 76 | + index++; | |
| 77 | + self.ld_currentIndex = index; | |
| 78 | +// [self.categoryView.delegate categoryView:self.categoryView didSelectedItemAtIndex:self.ld_currentIndex]; | |
| 79 | + return [self.controllersArr objectAtIndex:index]; | |
| 80 | +} | |
| 81 | + | |
| 82 | +#pragma mark - UIPageViewControllerDelegate | |
| 83 | +- (void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray<UIViewController *> *)pendingViewControllers { | |
| 84 | + UIViewController *nextVC = [pendingViewControllers firstObject]; | |
| 85 | + NSInteger index = [self.controllersArr indexOfObject:nextVC]; | |
| 86 | + self.ld_currentIndex = index; | |
| 87 | +} | |
| 88 | +- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray<UIViewController *> *)previousViewControllers transitionCompleted:(BOOL)completed { | |
| 89 | + if (completed) { | |
| 90 | + NSIndexPath *path = [NSIndexPath indexPathForRow:self.ld_currentIndex inSection:0]; | |
| 91 | + [self.categoryView.collectionView scrollToItemAtIndexPath:path atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES]; | |
| 92 | + [self.categoryView.delegate categoryView:self.categoryView didSelectedItemAtIndex:self.ld_currentIndex]; | |
| 93 | + [self.categoryView selectCellAtIndex:self.ld_currentIndex selectedType:JXCategoryCellSelectedTypeScroll]; | |
| 94 | + } | |
| 95 | +} | |
| 52 | 96 | #pragma mark - JXCategoryViewDelegate |
| 53 | 97 | -(void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index |
| 54 | 98 | { |
| 55 | 99 | self.navigationController.interactivePopGestureRecognizer.enabled = (index ==0); |
| 100 | + UIViewController *vc = self.controllersArr[index]; | |
| 101 | + if (index>self.ld_currentIndex) { | |
| 102 | + [self.pageViewController setViewControllers:@[vc] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL]; | |
| 103 | + }else | |
| 104 | + { | |
| 105 | + [self.pageViewController setViewControllers:@[vc] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:NULL]; | |
| 106 | + } | |
| 56 | 107 | } |
| 57 | 108 | |
| 58 | -#pragma mark - JXCategoryListContainerViewDelegate | |
| 59 | -- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView | |
| 60 | -{ | |
| 61 | - return self.titles.count; | |
| 62 | -} | |
| 63 | - | |
| 64 | --(id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index | |
| 65 | -{ | |
| 66 | - CNLiveListManager *list = [CNLiveListManager new]; | |
| 67 | - return list; | |
| 68 | -} | |
| 69 | 109 | |
| 70 | 110 | #pragma mark - Getting |
| 71 | 111 | -(JXCategoryBaseView *)categoryView |
| ... | ... | @@ -73,21 +113,30 @@ |
| 73 | 113 | if (!_categoryView) { |
| 74 | 114 | _categoryView = [self preferredCategoryView]; |
| 75 | 115 | _categoryView.delegate = self; |
| 76 | - _categoryView.listContainer = self.listContainerView; | |
| 77 | 116 | } |
| 78 | 117 | return _categoryView; |
| 79 | 118 | } |
| 80 | - | |
| 81 | -- (JXCategoryListContainerView *)listContainerView | |
| 119 | +-(UIPageViewController *)pageViewController | |
| 82 | 120 | { |
| 83 | - if (!_listContainerView) { | |
| 84 | - _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self]; | |
| 85 | - _listContainerView.scrollView.backgroundColor = [UIColor clearColor]; | |
| 86 | - _listContainerView.listCellBackgroundColor = [UIColor clearColor]; | |
| 121 | + if (!_pageViewController) { | |
| 122 | + NSDictionary *option = [NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:0] forKey:UIPageViewControllerOptionInterPageSpacingKey]; | |
| 123 | + _pageViewController = [[UIPageViewController alloc]initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:option]; | |
| 124 | + _pageViewController.delegate = self; | |
| 125 | + _pageViewController.dataSource = self; | |
| 87 | 126 | } |
| 88 | - return _listContainerView; | |
| 127 | + return _pageViewController; | |
| 128 | + | |
| 89 | 129 | } |
| 130 | +- (UIScrollView *)findScrollView{ | |
| 131 | +for(id subview in self.pageViewController.view.subviews){ | |
| 132 | +if([subview isKindOfClass:UIScrollView.class]){ | |
| 133 | + _findScrollView=subview; | |
| 134 | + break; | |
| 135 | +} | |
| 136 | +} | |
| 137 | +return _findScrollView; | |
| 90 | 138 | |
| 139 | +} | |
| 91 | 140 | -(NSMutableArray *)titles |
| 92 | 141 | { |
| 93 | 142 | if (!_titles) { |
| ... | ... | @@ -95,4 +144,13 @@ |
| 95 | 144 | } |
| 96 | 145 | return _titles; |
| 97 | 146 | } |
| 147 | + | |
| 148 | +-(NSMutableArray *)controllersArr | |
| 149 | +{ | |
| 150 | + if (!_controllersArr) { | |
| 151 | + _controllersArr = [[NSMutableArray alloc] init]; | |
| 152 | + } | |
| 153 | + return _controllersArr; | |
| 154 | +} | |
| 155 | + | |
| 98 | 156 | @end | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/CNLiveClassifySegmentController.m
| ... | ... | @@ -26,7 +26,6 @@ static const CGFloat animationHeight = 15; |
| 26 | 26 | @property (nonatomic, assign) CGFloat topBgImgHeight;//头部图片高度 |
| 27 | 27 | @property (nonatomic, assign) CGFloat lastOffsetY; |
| 28 | 28 | |
| 29 | -@property (nonatomic, assign) NSInteger currentIndex;//当前页 | |
| 30 | 29 | |
| 31 | 30 | @property (nonatomic, strong) NSString * currentAtatusColor; |
| 32 | 31 | |
| ... | ... | @@ -53,7 +52,7 @@ static CGFloat moveHeight = 50; |
| 53 | 52 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(classifyChannelsRequest:) name:CNWjjClassifyChannelsRequestStateNotifiName object:nil]; |
| 54 | 53 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(classifyChannelsRequestedHideLoading:) name:CNWjjClassifyChannelsRequestHideLoadingNotifiName object:nil]; |
| 55 | 54 | self.topBgImgHeight = kStatusHeight+100; |
| 56 | - self.currentIndex = 0; | |
| 55 | + self.ld_currentIndex = 0; | |
| 57 | 56 | [self.view addSubview:self.topBgImg]; |
| 58 | 57 | [self.view sendSubviewToBack:self.topBgImg]; |
| 59 | 58 | [self dataDivideIntoNormalAndOtherWithFirst:YES]; |
| ... | ... | @@ -64,7 +63,6 @@ static CGFloat moveHeight = 50; |
| 64 | 63 | { |
| 65 | 64 | [self.view addSubview:self.loginBtn]; |
| 66 | 65 | } |
| 67 | - self.myCategoryView.delegate = self; | |
| 68 | 66 | |
| 69 | 67 | self.myCategoryView.translatesAutoresizingMaskIntoConstraints = NO; |
| 70 | 68 | self.myCategoryView.titleColorGradientEnabled = YES; |
| ... | ... | @@ -78,7 +76,6 @@ static CGFloat moveHeight = 50; |
| 78 | 76 | self.myCategoryView.cellWidthZoomEnabled = YES; |
| 79 | 77 | self.myCategoryView.cellWidthZoomScale = 1.3; |
| 80 | 78 | self.myCategoryView.imageSize = CGSizeMake(56, 18); |
| 81 | - self.listContainerView.translatesAutoresizingMaskIntoConstraints = NO; | |
| 82 | 79 | if (!self.isLoading) { |
| 83 | 80 | [self uploadSubViews]; |
| 84 | 81 | } |
| ... | ... | @@ -89,7 +86,7 @@ static CGFloat moveHeight = 50; |
| 89 | 86 | -(void)viewDidLayoutSubviews |
| 90 | 87 | { |
| 91 | 88 | [super viewDidLayoutSubviews]; |
| 92 | - self.listContainerView.frame = CGRectMake(0,self.myCategoryView.bottom, kScreenWidth, self.view.height -kStatusHeight); | |
| 89 | + self.pageViewController.view.frame = CGRectMake(0, self.myCategoryView.bottom, kScreenWidth, self.view.bounds.size.height - self.myCategoryView.bottom+ moveHeight); | |
| 93 | 90 | if ([CNUserShareManager isLogin]) { |
| 94 | 91 | self.myCategoryView.width = kScreenWidth - 45; |
| 95 | 92 | self.customChannelsBtn.centerY = self.myCategoryView.centerY; |
| ... | ... | @@ -130,8 +127,8 @@ static CGFloat moveHeight = 50; |
| 130 | 127 | } |
| 131 | 128 | - (void)uploadSubViews |
| 132 | 129 | { |
| 133 | - if (self.currentIndex>=self.titles.count) { | |
| 134 | - self.currentIndex = 0; | |
| 130 | + if (self.ld_currentIndex>=self.titles.count) { | |
| 131 | + self.ld_currentIndex = 0; | |
| 135 | 132 | } |
| 136 | 133 | for (int i = 0;i<self.imageNames.count;i++) { |
| 137 | 134 | NSURL *url = [NSURL URLWithString:self.imageNames[i]]; |
| ... | ... | @@ -139,16 +136,48 @@ static CGFloat moveHeight = 50; |
| 139 | 136 | } |
| 140 | 137 | //分类控制器基础配置 |
| 141 | 138 | self.myCategoryView.titles = self.titles; |
| 142 | - self.myCategoryView.delegate = self; | |
| 143 | 139 | self.myCategoryView.imageURLs = self.imageNames; |
| 144 | - self.myCategoryView.defaultSelectedIndex = self.currentIndex; | |
| 140 | + self.myCategoryView.defaultSelectedIndex = self.ld_currentIndex; | |
| 145 | 141 | self.myCategoryView.loadImageCallback = ^(UIImageView *imageView, NSURL *imageURL) { |
| 146 | 142 | [imageView sd_setImageWithURL:imageURL]; |
| 147 | 143 | }; |
| 148 | - [self updateSelectColors:self.currentIndex]; | |
| 149 | - [self configCategoryViewWithType:JXCategoryTitleImageType_OnlyImage selectIndex:self.currentIndex unselectIndex:self.currentIndex]; | |
| 144 | + [self updateSelectColors:self.ld_currentIndex]; | |
| 145 | + [self configCategoryViewWithType:JXCategoryTitleImageType_OnlyImage selectIndex:self.ld_currentIndex unselectIndex:self.ld_currentIndex]; | |
| 146 | + | |
| 147 | + | |
| 148 | + for (int i = 0; i<self.titles.count; i++) { | |
| 149 | + CNCategoryGetChannelModel *model = self.dataArray[i]; | |
| 150 | + BOOL isBlack = NO; | |
| 151 | + if (CNLiveStringIsEmpty(model.statusBarColor)) { | |
| 152 | + isBlack = YES; | |
| 153 | + } else { | |
| 154 | + isBlack = [model.statusBarColor boolValue];//1 黑色 | |
| 155 | + } | |
| 156 | + if (model.pageStyleList.count>0) { | |
| 157 | + self.topBgImg.frame = CGRectMake(0, 0, KScreenWidth, self.topBgImgHeight); | |
| 158 | + CNLiveSubSegmentController *subVC = [[CNLiveSubSegmentController alloc] initWithModel:model]; | |
| 159 | + subVC.isBlack = isBlack; | |
| 160 | + weakself | |
| 161 | + subVC.scrollViewDidScrollBlock = ^(BOOL isUp) { | |
| 162 | + [weakSelf scrollViewUpDowm:isUp]; | |
| 163 | + }; | |
| 164 | + | |
| 165 | + [self.controllersArr addObject:subVC]; | |
| 166 | + }else{ | |
| 167 | + self.topBgImg.frame = CGRectMake(0, 0, KScreenWidth, self.topBgImgHeight - 50); | |
| 168 | + CNLiveListManager *list = [CNLiveListManager shareListManager]; | |
| 169 | + UIViewController *listVC = [list model:model black:isBlack bgImage:self.bgImages[i] bgColor:model.backgroundColor bgImageH5:model.backgroundImgH5]; | |
| 170 | + weakself | |
| 171 | + list.scrollViewDidScrollBlock = ^(BOOL isUp) { | |
| 172 | + [weakSelf scrollViewUpDowm:isUp]; | |
| 173 | + }; | |
| 174 | + [self.controllersArr addObject:listVC]; | |
| 175 | + } | |
| 176 | + } | |
| 177 | + [self addTheFirstPage]; | |
| 150 | 178 | } |
| 151 | 179 | |
| 180 | + | |
| 152 | 181 | #pragma mark - 通知的监听方法 Notification |
| 153 | 182 | // 分类接口请求成功或者失败 |
| 154 | 183 | - (void)classifyChannelsRequest:(NSNotification *)noti { |
| ... | ... | @@ -359,6 +388,7 @@ static CGFloat moveHeight = 50; |
| 359 | 388 | [self.textColors removeAllObjects]; |
| 360 | 389 | [self.textColorSeleteds removeAllObjects]; |
| 361 | 390 | [self.statusBarColors removeAllObjects]; |
| 391 | + [self.controllersArr removeAllObjects]; | |
| 362 | 392 | for (NSString *str in normalArray) { |
| 363 | 393 | NSDictionary *dic = CNLiveStringJsonToDictionary(str); |
| 364 | 394 | CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic]; |
| ... | ... | @@ -423,7 +453,7 @@ static CGFloat moveHeight = 50; |
| 423 | 453 | [self managerScrollView:YES]; |
| 424 | 454 | self.topBgImg.top -= moveHeight; |
| 425 | 455 | self.myCategoryView.collectionView.top = -50-kStatusHeight; |
| 426 | - self.listContainerView.top = kStatusHeight; | |
| 456 | + self.pageViewController.view.top = kStatusHeight; | |
| 427 | 457 | } |
| 428 | 458 | -(void)scrollViewDown{ |
| 429 | 459 | if (self.topBgImg.top==0) { |
| ... | ... | @@ -432,19 +462,17 @@ static CGFloat moveHeight = 50; |
| 432 | 462 | [self managerScrollView:NO]; |
| 433 | 463 | self.topBgImg.top += moveHeight; |
| 434 | 464 | self.myCategoryView.collectionView.top = 0; |
| 435 | - self.listContainerView.top = self.myCategoryView.bottom; | |
| 465 | + self.pageViewController.view.top = self.myCategoryView.bottom; | |
| 436 | 466 | |
| 437 | 467 | } |
| 438 | 468 | |
| 439 | 469 | -(void)managerScrollView:(BOOL)enabled |
| 440 | 470 | { |
| 441 | - self.listContainerView.scrollView.scrollEnabled = !enabled; | |
| 442 | - for (UIView *view in self.listContainerView.scrollView.subviews) { | |
| 443 | - if ([view.viewController isKindOfClass:[CNLiveSubSegmentController class]]) { | |
| 444 | - CNLiveSubSegmentController *subVc = (CNLiveSubSegmentController *)view.viewController; | |
| 445 | - [subVc layoutRightSubViewWithShow:!enabled]; | |
| 446 | - } | |
| 447 | - } | |
| 471 | + self.findScrollView.scrollEnabled = !enabled; | |
| 472 | + if ([self.pageViewController.viewControllers.firstObject isKindOfClass:[CNLiveSubSegmentController class]]) { | |
| 473 | + CNLiveSubSegmentController *subVc = (CNLiveSubSegmentController *)self.pageViewController.viewControllers.firstObject; | |
| 474 | + [subVc layoutRightSubViewWithShow:!enabled]; | |
| 475 | + } | |
| 448 | 476 | } |
| 449 | 477 | #pragma mark - CNCustomChannelListViewDelegate !!!!!!!!!!!!!!!!!!!!!! |
| 450 | 478 | - (void)changeChannelsList |
| ... | ... | @@ -492,51 +520,20 @@ static CGFloat moveHeight = 50; |
| 492 | 520 | } |
| 493 | 521 | |
| 494 | 522 | #pragma mark - JXCategoryViewDelegate |
| 495 | -// 正在滚动中的回调,这里调整背景图片的 alpha 透明度 | |
| 496 | -- (void)categoryView:(JXCategoryBaseView *)categoryView scrollingFromLeftIndex:(NSInteger)leftIndex toRightIndex:(NSInteger)rightIndex ratio:(CGFloat)ratio { | |
| 497 | - [self configCategoryViewWithType:JXCategoryTitleImageType_OnlyImage selectIndex:leftIndex unselectIndex:rightIndex]; | |
| 498 | -} | |
| 499 | - | |
| 500 | - | |
| 501 | 523 | - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index { |
| 502 | 524 | NSLog(@"%@", NSStringFromSelector(_cmd)); |
| 503 | - self.currentIndex = index; | |
| 525 | + UIViewController *vc = self.controllersArr[index]; | |
| 526 | + if (index>self.ld_currentIndex) { | |
| 527 | + [self.pageViewController setViewControllers:@[vc] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL]; | |
| 528 | + }else | |
| 529 | + { | |
| 530 | + [self.pageViewController setViewControllers:@[vc] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:NULL]; | |
| 531 | + } | |
| 504 | 532 | // 侧滑手势处理 |
| 505 | 533 | self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0); |
| 506 | 534 | [self updateSelectColors:index]; |
| 507 | 535 | [self configCategoryViewWithType:JXCategoryTitleImageType_OnlyImage selectIndex:index unselectIndex:index]; |
| 508 | -} | |
| 509 | -#pragma mark - JXCategoryListContainerViewDelegate | |
| 510 | --(id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index | |
| 511 | -{ | |
| 512 | - CNCategoryGetChannelModel *model = self.dataArray[index]; | |
| 513 | - BOOL isBlack = NO; | |
| 514 | - if (CNLiveStringIsEmpty(model.statusBarColor)) { | |
| 515 | - isBlack = YES; | |
| 516 | - } else { | |
| 517 | - isBlack = [model.statusBarColor boolValue];//1 黑色 | |
| 518 | - } | |
| 519 | - if (model.pageStyleList.count>0) { | |
| 520 | - self.topBgImg.frame = CGRectMake(0, 0, KScreenWidth, self.topBgImgHeight); | |
| 521 | - CNLiveSubSegmentController *subVC = [[CNLiveSubSegmentController alloc] initWithModel:model]; | |
| 522 | - subVC.isBlack = isBlack; | |
| 523 | - weakself | |
| 524 | - subVC.scrollViewDidScrollBlock = ^(BOOL isUp) { | |
| 525 | - [weakSelf scrollViewUpDowm:isUp]; | |
| 526 | - }; | |
| 527 | - | |
| 528 | - return subVC; | |
| 529 | - } | |
| 530 | - self.topBgImg.frame = CGRectMake(0, 0, KScreenWidth, self.topBgImgHeight - 50); | |
| 531 | - CNLiveListManager *list = [CNLiveListManager shareListManager]; | |
| 532 | - UIViewController *listView = [list model:model black:isBlack bgImage:[self.bgImages safetyObjectAtIndex:index] bgColor:model.backgroundColor bgImageH5:model.backgroundImgH5]; | |
| 533 | - list.contentVC = self; | |
| 534 | - weakself | |
| 535 | - list.scrollViewDidScrollBlock = ^(BOOL isUp) { | |
| 536 | - [weakSelf scrollViewUpDowm:isUp]; | |
| 537 | - }; | |
| 538 | - | |
| 539 | - return listView; | |
| 536 | + | |
| 540 | 537 | } |
| 541 | 538 | #pragma mark - Public |
| 542 | 539 | -(JXCategoryBaseView *)preferredCategoryView | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/CNLiveListViewController.h deleted
100644 → 0
| 1 | -// | |
| 2 | -// CNLiveListViewController.h | |
| 3 | -// CNLiveVideoClassifyKit | |
| 4 | -// | |
| 5 | -// Created by CNLive on 2021/9/10. | |
| 6 | -// | |
| 7 | - | |
| 8 | -#import <CNLiveBaseClass/CNLiveBaseClass.h> | |
| 9 | - | |
| 10 | -NS_ASSUME_NONNULL_BEGIN | |
| 11 | - | |
| 12 | -@interface CNLiveListViewController : CNLiveBaseViewController | |
| 13 | - | |
| 14 | -@end | |
| 15 | - | |
| 16 | -NS_ASSUME_NONNULL_END |
CNLiveVideoClassifyKit/Classes/Controller/CNLiveListViewController.m deleted
100644 → 0
| 1 | -// | |
| 2 | -// CNLiveListViewController.m | |
| 3 | -// CNLiveVideoClassifyKit | |
| 4 | -// | |
| 5 | -// Created by CNLive on 2021/9/10. | |
| 6 | -// | |
| 7 | - | |
| 8 | -#import "CNLiveListViewController.h" | |
| 9 | - | |
| 10 | -@interface CNLiveListViewController () | |
| 11 | - | |
| 12 | -@end | |
| 13 | - | |
| 14 | -@implementation CNLiveListViewController | |
| 15 | - | |
| 16 | -- (void)viewDidLoad { | |
| 17 | - [super viewDidLoad]; | |
| 18 | - self.navigationHidden = YES; | |
| 19 | - // Do any additional setup after loading the view. | |
| 20 | -} | |
| 21 | - | |
| 22 | -/* | |
| 23 | -#pragma mark - Navigation | |
| 24 | - | |
| 25 | -// In a storyboard-based application, you will often want to do a little preparation before navigation | |
| 26 | -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
| 27 | - // Get the new view controller using [segue destinationViewController]. | |
| 28 | - // Pass the selected object to the new view controller. | |
| 29 | -} | |
| 30 | -*/ | |
| 31 | - | |
| 32 | -@end |
CNLiveVideoClassifyKit/Classes/Controller/CNLiveSubSegmentController.h
| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | |
| 11 | 11 | NS_ASSUME_NONNULL_BEGIN |
| 12 | 12 | |
| 13 | -@interface CNLiveSubSegmentController : CNCategoryBaseViewController<JXCategoryListContentViewDelegate> | |
| 13 | +@interface CNLiveSubSegmentController : CNCategoryBaseViewController | |
| 14 | 14 | |
| 15 | 15 | @property (nonatomic, assign) BOOL isBlack; |
| 16 | 16 | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/CNLiveSubSegmentController.m
| ... | ... | @@ -53,10 +53,11 @@ |
| 53 | 53 | |
| 54 | 54 | - (void)viewDidLoad { |
| 55 | 55 | [super viewDidLoad]; |
| 56 | + [self handleDateWithChannelsArray]; | |
| 56 | 57 | // 添加二级频道右侧的搜索按钮 |
| 57 | 58 | [self.view addSubview:self.searchBtn]; |
| 58 | 59 | self.view.backgroundColor = [UIColor clearColor]; |
| 59 | - [self handleDateWithChannelsArray]; | |
| 60 | + self.findScrollView.scrollEnabled = NO; | |
| 60 | 61 | self.myCategoryView.titles = self.titles; |
| 61 | 62 | if (CNLiveStringIsEmpty(self.backImage)) { |
| 62 | 63 | self.view.backgroundColor = CNLiveColorWithHexString(self.backgroundColor); |
| ... | ... | @@ -72,7 +73,19 @@ |
| 72 | 73 | lineView.indicatorColor = self.textColor; |
| 73 | 74 | self.myCategoryView.indicators = @[lineView]; |
| 74 | 75 | [self.categoryView reloadData]; |
| 75 | - self.listContainerView.scrollView.scrollEnabled = NO; | |
| 76 | + | |
| 77 | + for (int i = 0; i<self.titles.count; i++) { | |
| 78 | + CNCategoryGetChannelModel *model = self.pageListArr[i]; | |
| 79 | + CNLiveListManager *list = [CNLiveListManager shareListManager]; | |
| 80 | + UIViewController *listVC = [list model:model black:_isBlack bgImage:self.backImage bgColor:self.backgroundColor bgImageH5:self.backImageH5]; | |
| 81 | + | |
| 82 | + weakself | |
| 83 | + list.scrollViewDidScrollBlock = ^(BOOL isUp) { | |
| 84 | + !weakSelf.scrollViewDidScrollBlock ?: weakSelf.scrollViewDidScrollBlock(isUp); | |
| 85 | + }; | |
| 86 | + [self.controllersArr addObject:listVC]; | |
| 87 | + } | |
| 88 | + [self addTheFirstPage]; | |
| 76 | 89 | // Do any additional setup after loading the view. |
| 77 | 90 | } |
| 78 | 91 | -(void)viewDidLayoutSubviews |
| ... | ... | @@ -82,8 +95,7 @@ |
| 82 | 95 | self.searchBtn.centerY = self.myCategoryView.height/2; |
| 83 | 96 | self.myCategoryView.top = 0; |
| 84 | 97 | self.myCategoryView.width = self.searchBtn.left; |
| 85 | - self.listContainerView.frame = CGRectMake(0, [self preferredCategoryViewHeight]+10, self.view.bounds.size.width, self.view.bounds.size.height - [self preferredCategoryViewHeight]); | |
| 86 | - | |
| 98 | + self.pageViewController.view.frame = CGRectMake(0, self.myCategoryView.bottom+10, kScreenWidth, self.view.bounds.size.height - self.myCategoryView.bottom); | |
| 87 | 99 | } |
| 88 | 100 | #pragma mark - Method |
| 89 | 101 | -(void)handleDateWithChannelsArray{ |
| ... | ... | @@ -95,8 +107,7 @@ |
| 95 | 107 | } |
| 96 | 108 | // 一级频道显示隐藏时二级频道右侧的搜索按钮变宽变窄控制 |
| 97 | 109 | - (void)layoutRightSubViewWithShow:(BOOL)show { |
| 98 | - | |
| 99 | - self.listContainerView.scrollView.scrollEnabled = !show; | |
| 110 | + self.findScrollView.scrollEnabled = !show; | |
| 100 | 111 | if (show) { |
| 101 | 112 | // 正常 |
| 102 | 113 | |
| ... | ... | @@ -137,30 +148,19 @@ |
| 137 | 148 | { |
| 138 | 149 | return 40; |
| 139 | 150 | } |
| 140 | -#pragma mark - JXCategoryListContainerViewDelegate | |
| 141 | - | |
| 142 | --(id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index | |
| 151 | +#pragma mark - JXCategoryViewDelegate | |
| 152 | +-(void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index | |
| 143 | 153 | { |
| 144 | - CNCategoryGetChannelModel *model = self.pageListArr[index]; | |
| 145 | - CNLiveListManager *list = [CNLiveListManager shareListManager]; | |
| 146 | - UIViewController *listView = [list model:model black:_isBlack bgImage:self.backImage bgColor:self.backgroundColor bgImageH5:self.backImageH5]; | |
| 147 | - list.contentVC = self; | |
| 148 | - weakself | |
| 149 | - list.scrollViewDidScrollBlock = ^(BOOL isUp) { | |
| 150 | - !weakSelf.scrollViewDidScrollBlock ?: weakSelf.scrollViewDidScrollBlock(isUp); | |
| 151 | - }; | |
| 152 | - | |
| 153 | - return listView; | |
| 154 | -} | |
| 155 | -#pragma mark - JXCategoryListContentViewDelegate | |
| 154 | + self.navigationController.interactivePopGestureRecognizer.enabled = (index ==0); | |
| 155 | + UIViewController *vc = self.controllersArr[index]; | |
| 156 | + if (index>self.ld_currentIndex) { | |
| 157 | + [self.pageViewController setViewControllers:@[vc] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL]; | |
| 158 | + }else | |
| 159 | + { | |
| 160 | + [self.pageViewController setViewControllers:@[vc] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:NULL]; | |
| 161 | + } | |
| 156 | 162 | |
| 157 | -/** | |
| 158 | - 实现 <JXCategoryListContentViewDelegate> 协议方法,返回该视图控制器所拥有的「视图」 | |
| 159 | - */ | |
| 160 | -- (UIView *)listView { | |
| 161 | - return self.view; | |
| 162 | 163 | } |
| 163 | - | |
| 164 | 164 | #pragma mark - Getting&&Setting |
| 165 | 165 | -(JXCategoryTitleView *)myCategoryView |
| 166 | 166 | { | ... | ... |
CNLiveVideoClassifyKit/Classes/Manager/CNLiveListManager.h
| ... | ... | @@ -7,12 +7,12 @@ |
| 7 | 7 | |
| 8 | 8 | #import <Foundation/Foundation.h> |
| 9 | 9 | @class CNCategoryGetChannelModel; |
| 10 | +@class CNLiveListViewController; | |
| 10 | 11 | |
| 11 | 12 | NS_ASSUME_NONNULL_BEGIN |
| 12 | 13 | |
| 13 | -@interface CNLiveListManager : NSObject<JXCategoryListContentViewDelegate> | |
| 14 | +@interface CNLiveListManager : NSObject | |
| 14 | 15 | @property (nonatomic, copy) void (^scrollViewDidScrollBlock)(BOOL isUp); |
| 15 | -@property (nonatomic, weak) UIViewController *contentVC; | |
| 16 | 16 | |
| 17 | 17 | +(instancetype)shareListManager; |
| 18 | 18 | ... | ... |
CNLiveVideoClassifyKit/Classes/Manager/CNLiveListManager.m
| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | |
| 11 | 11 | @interface CNLiveListManager() |
| 12 | 12 | { |
| 13 | - UIViewController *subVC; | |
| 14 | 13 | CGFloat beginoffsetY; |
| 15 | 14 | } |
| 16 | 15 | @end |
| ... | ... | @@ -50,7 +49,7 @@ |
| 50 | 49 | @"backgroundImgH5":bgImageH5?bgImageH5:@"" |
| 51 | 50 | }; |
| 52 | 51 | } |
| 53 | - subVC = [CNLiveClassifyJumpBridge ListViewWithPageType:model.pageType.integerValue param:paramDic]; | |
| 52 | + UIViewController *subVC = [CNLiveClassifyJumpBridge ListViewWithPageType:model.pageType.integerValue param:paramDic]; | |
| 54 | 53 | return subVC; |
| 55 | 54 | } |
| 56 | 55 | - (void)requestWebViewForScrollView:(nonnull UIScrollView *)scrollView isBeginDragging:(BOOL)isBeginDragging |
| ... | ... | @@ -67,13 +66,4 @@ |
| 67 | 66 | } |
| 68 | 67 | } |
| 69 | 68 | |
| 70 | - | |
| 71 | -#pragma mark - JXCategoryListContentViewDelegate | |
| 72 | - | |
| 73 | -/** | |
| 74 | - 实现 <JXCategoryListContentViewDelegate> 协议方法,返回该视图控制器所拥有的「视图」 | |
| 75 | - */ | |
| 76 | -- (UIView *)listView { | |
| 77 | - return subVC.view; | |
| 78 | -} | |
| 79 | 69 | @end | ... | ... |
Example/CNLiveVideoClassifyKit/CNLIVEDemoViewController.m
| ... | ... | @@ -19,7 +19,12 @@ |
| 19 | 19 | self.view.backgroundColor = [UIColor greenColor]; |
| 20 | 20 | // Do any additional setup after loading the view. |
| 21 | 21 | } |
| 22 | - | |
| 22 | +-(void)viewDidAppear:(BOOL)animated | |
| 23 | +{ | |
| 24 | + [super viewDidAppear:animated]; | |
| 25 | + self.navigationController.navigationBarHidden = YES; | |
| 26 | + | |
| 27 | +} | |
| 23 | 28 | /* |
| 24 | 29 | #pragma mark - Navigation |
| 25 | 30 | ... | ... |
Example/CNLiveVideoClassifyKit/CNLIVEViewController.m
| ... | ... | @@ -40,11 +40,17 @@ |
| 40 | 40 | - (void)viewDidLoad |
| 41 | 41 | { |
| 42 | 42 | [super viewDidLoad]; |
| 43 | + | |
| 43 | 44 | [CNTools GetClassifyChannelsUrlsAndSave]; |
| 44 | 45 | self.title = @"首页"; |
| 45 | 46 | segArr = @[@"分类"]; |
| 46 | 47 | [self.view addSubview:self.collectionView]; |
| 47 | 48 | } |
| 49 | +-(void)viewDidAppear:(BOOL)animated | |
| 50 | +{ | |
| 51 | + [super viewDidAppear:animated]; | |
| 52 | + self.navigationController.navigationBarHidden = YES; | |
| 53 | +} | |
| 48 | 54 | #pragma mrk - UICollectionViewDataSource |
| 49 | 55 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section |
| 50 | 56 | { | ... | ... |