Commit 65625927db1676575cdc6cb48bac77c23b9f2507
1 parent
f6e4752a
UIpageController 不好控制scroll的滑动效果,替换ContaintView
Showing
10 changed files
with
185 additions
and
205 deletions
CNLiveVideoClassifyKit.podspec
CNLiveVideoClassifyKit/Classes/Controller/CNCategoryBaseViewController.h
| ... | ... | @@ -9,20 +9,16 @@ |
| 9 | 9 | |
| 10 | 10 | NS_ASSUME_NONNULL_BEGIN |
| 11 | 11 | |
| 12 | -@interface CNCategoryBaseViewController : UIViewController<JXCategoryViewDelegate,UIPageViewControllerDelegate,UIPageViewControllerDataSource> | |
| 12 | +@interface CNCategoryBaseViewController : UIViewController<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate> | |
| 13 | 13 | |
| 14 | 14 | @property (nonatomic, strong) JXCategoryBaseView *categoryView; |
| 15 | -@property (nonatomic, strong) UIPageViewController *pageViewController; | |
| 16 | -@property (nonatomic, strong) UIScrollView *findScrollView;//控制器的scrollView | |
| 15 | +@property (nonatomic, strong) JXCategoryListContainerView *listContainerView; | |
| 17 | 16 | @property (nonatomic, strong) NSMutableArray *titles;//标题 |
| 18 | -@property (nonatomic, strong) NSMutableArray *controllersArr;/// 控制器数组 | |
| 19 | - | |
| 20 | 17 | @property (nonatomic, assign) NSInteger ld_currentIndex; //当前选中 |
| 21 | 18 | |
| 22 | --(void)addTheFirstPage; //默认页 | |
| 23 | 19 | -(JXCategoryBaseView *)preferredCategoryView; |
| 24 | 20 | -(CGFloat)preferredCategoryViewHeight; |
| 25 | --(void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index; | |
| 21 | +- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index; | |
| 26 | 22 | @end |
| 27 | 23 | |
| 28 | 24 | NS_ASSUME_NONNULL_END | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/CNCategoryBaseViewController.m
| ... | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 | // 分类控制器根类 |
| 7 | 7 | |
| 8 | 8 | #import "CNCategoryBaseViewController.h" |
| 9 | +#import "CNLiveListController.h" | |
| 9 | 10 | |
| 10 | 11 | @interface CNCategoryBaseViewController () |
| 11 | 12 | @end |
| ... | ... | @@ -15,8 +16,7 @@ |
| 15 | 16 | - (void)viewDidLoad { |
| 16 | 17 | [super viewDidLoad]; |
| 17 | 18 | [self.view addSubview: self.categoryView]; |
| 18 | - [self addChildViewController:self.pageViewController]; | |
| 19 | - [self.view addSubview:self.pageViewController.view]; | |
| 19 | + [self.view addSubview:self.listContainerView]; | |
| 20 | 20 | self.view.backgroundColor = [UIColor whiteColor]; |
| 21 | 21 | |
| 22 | 22 | // Do any additional setup after loading the view. |
| ... | ... | @@ -27,6 +27,7 @@ |
| 27 | 27 | [super viewDidLayoutSubviews]; |
| 28 | 28 | |
| 29 | 29 | self.categoryView.frame = CGRectMake(0, kStatusHeight, self.view.bounds.size.width, [self preferredCategoryViewHeight]); |
| 30 | + self.listContainerView.frame = CGRectMake(0, [self preferredCategoryViewHeight], self.view.bounds.size.width, self.view.bounds.size.height); | |
| 30 | 31 | } |
| 31 | 32 | -(void)viewWillAppear:(BOOL)animated |
| 32 | 33 | { |
| ... | ... | @@ -37,13 +38,7 @@ |
| 37 | 38 | } |
| 38 | 39 | |
| 39 | 40 | #pragma mark - Public |
| 40 | --(void)addTheFirstPage{ | |
| 41 | - UIViewController *vc = self.controllersArr[self.ld_currentIndex]; | |
| 42 | - [self.pageViewController setViewControllers:@[vc] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:nil]; | |
| 43 | -} | |
| 44 | -- (void)configCategoryViewWithType:(JXCategoryTitleImageType)imageType selectIndex:(NSInteger)index unselectIndex:(NSInteger)unIndex{ | |
| 45 | - | |
| 46 | -} | |
| 41 | + | |
| 47 | 42 | -(JXCategoryBaseView *)preferredCategoryView{ |
| 48 | 43 | return [[JXCategoryBaseView alloc] init]; |
| 49 | 44 | } |
| ... | ... | @@ -53,57 +48,19 @@ |
| 53 | 48 | return 50; |
| 54 | 49 | } |
| 55 | 50 | |
| 56 | -#pragma mark - UIPageViewControllerDataSource | |
| 57 | -/// 展示上一页 | |
| 58 | -- (nullable UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController { | |
| 59 | - NSInteger index = self.ld_currentIndex; | |
| 60 | - if (index == 0 || (index == NSNotFound)) { | |
| 61 | - return nil; | |
| 62 | - } | |
| 63 | - index--; | |
| 64 | - self.ld_currentIndex = index; | |
| 65 | -// [self.categoryView.delegate categoryView:self.categoryView didSelectedItemAtIndex:self.ld_currentIndex]; | |
| 66 | - return [self.controllersArr objectAtIndex:index]; | |
| 67 | -} | |
| 68 | -/// 展示下一页 | |
| 69 | -- (nullable UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController { | |
| 70 | - NSInteger index = self.ld_currentIndex; | |
| 71 | - if (index == self.controllersArr.count - 1 || (index == NSNotFound)) { | |
| 72 | - return nil; | |
| 73 | - } | |
| 74 | - index++; | |
| 75 | - self.ld_currentIndex = index; | |
| 76 | -// [self.categoryView.delegate categoryView:self.categoryView didSelectedItemAtIndex:self.ld_currentIndex]; | |
| 77 | - return [self.controllersArr objectAtIndex:index]; | |
| 51 | +#pragma mark - JXCategoryListContainerViewDelegate | |
| 52 | +- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView | |
| 53 | +{ | |
| 54 | + return self.titles.count; | |
| 78 | 55 | } |
| 79 | - | |
| 80 | -#pragma mark - UIPageViewControllerDelegate | |
| 81 | -- (void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray<UIViewController *> *)pendingViewControllers { | |
| 82 | - UIViewController *nextVC = [pendingViewControllers firstObject]; | |
| 83 | - NSInteger index = [self.controllersArr indexOfObject:nextVC]; | |
| 84 | - self.ld_currentIndex = index; | |
| 85 | -} | |
| 86 | -- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray<UIViewController *> *)previousViewControllers transitionCompleted:(BOOL)completed { | |
| 87 | - if (completed) { | |
| 88 | - NSIndexPath *path = [NSIndexPath indexPathForRow:self.ld_currentIndex inSection:0]; | |
| 89 | - [self.categoryView.collectionView scrollToItemAtIndexPath:path atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES]; | |
| 90 | - [self.categoryView.delegate categoryView:self.categoryView didSelectedItemAtIndex:self.ld_currentIndex]; | |
| 91 | - [self.categoryView selectCellAtIndex:self.ld_currentIndex selectedType:JXCategoryCellSelectedTypeScroll]; | |
| 92 | - } | |
| 56 | +- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{ | |
| 57 | + return [CNLiveListController new]; | |
| 93 | 58 | } |
| 94 | 59 | #pragma mark - JXCategoryViewDelegate |
| 95 | --(void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index | |
| 60 | +- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index | |
| 96 | 61 | { |
| 97 | 62 | self.navigationController.interactivePopGestureRecognizer.enabled = (index ==0); |
| 98 | - UIViewController *vc = self.controllersArr[index]; | |
| 99 | - vc.navigationController.navigationBarHidden = YES; | |
| 100 | - if (index>self.ld_currentIndex) { | |
| 101 | - [self.pageViewController setViewControllers:@[vc] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL]; | |
| 102 | - }else | |
| 103 | - { | |
| 104 | - self.ld_currentIndex = index; | |
| 105 | - [self.pageViewController setViewControllers:@[vc] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:NULL]; | |
| 106 | - } | |
| 63 | + self.ld_currentIndex = index; | |
| 107 | 64 | } |
| 108 | 65 | |
| 109 | 66 | |
| ... | ... | @@ -113,29 +70,16 @@ |
| 113 | 70 | if (!_categoryView) { |
| 114 | 71 | _categoryView = [self preferredCategoryView]; |
| 115 | 72 | _categoryView.delegate = self; |
| 73 | + _categoryView.listContainer = self.listContainerView; | |
| 116 | 74 | } |
| 117 | 75 | return _categoryView; |
| 118 | 76 | } |
| 119 | --(UIPageViewController *)pageViewController | |
| 120 | -{ | |
| 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; | |
| 77 | +// 列表容器视图 | |
| 78 | +- (JXCategoryListContainerView *)listContainerView { | |
| 79 | + if (!_listContainerView) { | |
| 80 | + _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self]; | |
| 126 | 81 | } |
| 127 | - return _pageViewController; | |
| 128 | - | |
| 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; | |
| 138 | - | |
| 82 | + return _listContainerView; | |
| 139 | 83 | } |
| 140 | 84 | -(NSMutableArray *)titles |
| 141 | 85 | { |
| ... | ... | @@ -145,12 +89,5 @@ return _findScrollView; |
| 145 | 89 | return _titles; |
| 146 | 90 | } |
| 147 | 91 | |
| 148 | --(NSMutableArray *)controllersArr | |
| 149 | -{ | |
| 150 | - if (!_controllersArr) { | |
| 151 | - _controllersArr = [[NSMutableArray alloc] init]; | |
| 152 | - } | |
| 153 | - return _controllersArr; | |
| 154 | -} | |
| 155 | 92 | |
| 156 | 93 | @end | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/CNLiveClassifySegmentController.m
| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | #import "CNWebRedirectHandle.h" |
| 14 | 14 | #import "CNWitnessShadeManager.h" |
| 15 | 15 | #import "CNSupervisionGuideViewManager.h" |
| 16 | +#import "CNLiveListController.h" | |
| 16 | 17 | |
| 17 | 18 | static const CGFloat animationTime = 0.3; |
| 18 | 19 | static const CGFloat animationHeight = 15; |
| ... | ... | @@ -116,7 +117,8 @@ static CGFloat moveHeight = 50; |
| 116 | 117 | if ([CNWebRedirectHandle manager].isClickedIntegral) { |
| 117 | 118 | [CNWebRedirectHandle manager].isClickedIntegral = NO; |
| 118 | 119 | [self categoryView:self.myCategoryView didSelectedItemAtIndex:[CNWebRedirectHandle manager].channelId]; |
| 119 | - CNLiveSubSegmentController *svc = [self.controllersArr safetyObjectAtIndex:[CNWebRedirectHandle manager].classifyId]; | |
| 120 | + NSNumber *key = @([CNWebRedirectHandle manager].classifyId); | |
| 121 | + CNLiveSubSegmentController *svc = (CNLiveSubSegmentController *)self.listContainerView.validListDict[key]; | |
| 120 | 122 | if([svc isKindOfClass:[CNLiveSubSegmentController class]]){ |
| 121 | 123 | //目击者 - 今日要闻 - 中国冰雪 |
| 122 | 124 | [svc categoryView:svc.categoryView didSelectedItemAtIndex:[CNWebRedirectHandle manager].classifyId]; |
| ... | ... | @@ -168,6 +170,10 @@ static CGFloat moveHeight = 50; |
| 168 | 170 | { |
| 169 | 171 | [self.view addSubview:self.loginBtn]; |
| 170 | 172 | } |
| 173 | + weakself | |
| 174 | + [CNLiveListManager shareListManager].scrollViewDidScrollBlock = ^(BOOL isUp) { | |
| 175 | + [weakSelf scrollViewUpDowm:isUp]; | |
| 176 | + }; | |
| 171 | 177 | // Do any additional setup after loading the view. |
| 172 | 178 | } |
| 173 | 179 | -(void)viewWillAppear:(BOOL)animated { |
| ... | ... | @@ -203,7 +209,7 @@ static CGFloat moveHeight = 50; |
| 203 | 209 | -(void)viewDidLayoutSubviews |
| 204 | 210 | { |
| 205 | 211 | [super viewDidLayoutSubviews]; |
| 206 | - self.pageViewController.view.frame = CGRectMake(0, self.myCategoryView.bottom, kScreenWidth, self.view.bounds.size.height - self.myCategoryView.bottom+ moveHeight); | |
| 212 | + self.listContainerView.frame = CGRectMake(0, self.myCategoryView.bottom, kScreenWidth, self.view.bounds.size.height - self.myCategoryView.bottom+ moveHeight); | |
| 207 | 213 | if ([CNUserShareManager isLogin]) { |
| 208 | 214 | self.myCategoryView.width = kScreenWidth - 45; |
| 209 | 215 | self.customChannelsBtn.centerY = [self preferredCategoryViewHeight]/2 + kStatusHeight; |
| ... | ... | @@ -247,42 +253,6 @@ static CGFloat moveHeight = 50; |
| 247 | 253 | }; |
| 248 | 254 | [self updateSelectColors:self.ld_currentIndex]; |
| 249 | 255 | [self configCategoryViewWithType:JXCategoryTitleImageType_OnlyImage selectIndex:self.ld_currentIndex unselectIndex:self.ld_currentIndex]; |
| 250 | - | |
| 251 | - | |
| 252 | - for (int i = 0; i<self.titles.count; i++) { | |
| 253 | - CNCategoryGetChannelModel *model = self.dataArray[i]; | |
| 254 | - BOOL isBlack = NO; | |
| 255 | - if (CNLiveStringIsEmpty(model.statusBarColor)) { | |
| 256 | - isBlack = YES; | |
| 257 | - } else { | |
| 258 | - isBlack = [model.statusBarColor boolValue];//1 黑色 | |
| 259 | - } | |
| 260 | - if (model.pageStyleList.count>0) { | |
| 261 | - self.topBgImg.frame = CGRectMake(0, 0, KScreenWidth, self.topBgImgHeight); | |
| 262 | - CNLiveSubSegmentController *subVC = [[CNLiveSubSegmentController alloc] initWithModel:model]; | |
| 263 | - subVC.isBlack = isBlack; | |
| 264 | - subVC.delegate = self; | |
| 265 | - if (i == self.isLoginIndex) { | |
| 266 | - subVC.selectChannelId = i; | |
| 267 | - } | |
| 268 | - weakself | |
| 269 | - subVC.scrollViewDidScrollBlock = ^(BOOL isUp) { | |
| 270 | - [weakSelf scrollViewUpDowm:isUp]; | |
| 271 | - }; | |
| 272 | - | |
| 273 | - [self.controllersArr addObject:subVC]; | |
| 274 | - }else{ | |
| 275 | - self.topBgImg.frame = CGRectMake(0, 0, KScreenWidth, self.topBgImgHeight - 50); | |
| 276 | - CNLiveListManager *list = [CNLiveListManager shareListManager]; | |
| 277 | - UIViewController *listVC = [list model:model black:isBlack bgImage:self.bgImages[i] bgColor:model.backgroundColor bgImageH5:model.backgroundImgH5]; | |
| 278 | - weakself | |
| 279 | - list.scrollViewDidScrollBlock = ^(BOOL isUp) { | |
| 280 | - [weakSelf scrollViewUpDowm:isUp]; | |
| 281 | - }; | |
| 282 | - [self.controllersArr addObject:listVC]; | |
| 283 | - } | |
| 284 | - } | |
| 285 | - [self addTheFirstPage]; | |
| 286 | 256 | self.isLoad = YES; |
| 287 | 257 | if (![CNUserShareManager isLogin]) { |
| 288 | 258 | [CNLiveClassifyJumpBridge bringCenterLoginViewToFront]; |
| ... | ... | @@ -341,12 +311,12 @@ static CGFloat moveHeight = 50; |
| 341 | 311 | |
| 342 | 312 | // 电商中国可以下拉出地图页面 当下拉出地图页面时不可以左右滚动 |
| 343 | 313 | - (void)PageControlScrollEnable:(NSNotification *)noti { |
| 344 | - if (!self.findScrollView.isScrollEnabled) { | |
| 314 | + if (!self.listContainerView.scrollView.isScrollEnabled) { | |
| 345 | 315 | return; |
| 346 | 316 | } |
| 347 | 317 | BOOL scrollEnable = [noti.object boolValue]; |
| 348 | 318 | NSLog(@"是否可滚动:%d",scrollEnable); |
| 349 | - self.findScrollView.scrollEnabled = scrollEnable; | |
| 319 | + self.listContainerView.scrollView.scrollEnabled = scrollEnable; | |
| 350 | 320 | } |
| 351 | 321 | |
| 352 | 322 | - (void)touristsLoginTipsViewIsClassify:(NSNotification *)noti{ |
| ... | ... | @@ -606,7 +576,6 @@ static CGFloat moveHeight = 50; |
| 606 | 576 | [self.textColors removeAllObjects]; |
| 607 | 577 | [self.textColorSeleteds removeAllObjects]; |
| 608 | 578 | [self.statusBarColors removeAllObjects]; |
| 609 | - [self.controllersArr removeAllObjects]; | |
| 610 | 579 | for (NSString *str in normalArray) { |
| 611 | 580 | NSDictionary *dic = CNLiveStringJsonToDictionary(str); |
| 612 | 581 | CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic]; |
| ... | ... | @@ -658,10 +627,10 @@ static CGFloat moveHeight = 50; |
| 658 | 627 | } |
| 659 | 628 | -(void)scrollViewUpDowm:(BOOL)isUp |
| 660 | 629 | { |
| 661 | - if (isUp != self.findScrollView.isScrollEnabled) { | |
| 630 | + if (isUp != self.listContainerView.scrollView.isScrollEnabled) { | |
| 662 | 631 | return; |
| 663 | 632 | } |
| 664 | - self.findScrollView.scrollEnabled = !isUp; | |
| 633 | + self.listContainerView.scrollView.scrollEnabled = !isUp; | |
| 665 | 634 | self.isHiddenFirst = isUp; |
| 666 | 635 | [UIView animateWithDuration:0.3 animations:^{ |
| 667 | 636 | if (isUp) { |
| ... | ... | @@ -676,7 +645,7 @@ static CGFloat moveHeight = 50; |
| 676 | 645 | -(void)scrollViewUp{ |
| 677 | 646 | self.topBgImg.top -= moveHeight; |
| 678 | 647 | self.myCategoryView.collectionView.top = -50-kStatusHeight; |
| 679 | - self.pageViewController.view.top = kStatusHeight; | |
| 648 | + self.listContainerView.top = kStatusHeight; | |
| 680 | 649 | if ([CNUserShareManager isLogin]) { |
| 681 | 650 | self.customChannelsBtn.centerY = self.myCategoryView.collectionView.centerY + kStatusHeight; |
| 682 | 651 | }else |
| ... | ... | @@ -687,7 +656,7 @@ static CGFloat moveHeight = 50; |
| 687 | 656 | -(void)scrollViewDown{ |
| 688 | 657 | self.topBgImg.top += moveHeight; |
| 689 | 658 | self.myCategoryView.collectionView.top = 0; |
| 690 | - self.pageViewController.view.top = self.myCategoryView.bottom; | |
| 659 | + self.listContainerView.top = self.myCategoryView.bottom; | |
| 691 | 660 | if ([CNUserShareManager isLogin]) { |
| 692 | 661 | self.customChannelsBtn.centerY = self.myCategoryView.centerY; |
| 693 | 662 | }else |
| ... | ... | @@ -808,18 +777,36 @@ static CGFloat moveHeight = 50; |
| 808 | 777 | self.customChannelsV = nil; |
| 809 | 778 | }]; |
| 810 | 779 | } |
| 780 | +#pragma mark - JXCategoryListContainerViewDelegate | |
| 781 | +- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{ | |
| 782 | + CNCategoryGetChannelModel *model = self.dataArray[index]; | |
| 783 | + BOOL isBlack = NO; | |
| 784 | + if (CNLiveStringIsEmpty(model.statusBarColor)) { | |
| 785 | + isBlack = YES; | |
| 786 | + } else { | |
| 787 | + isBlack = [model.statusBarColor boolValue];//1 黑色 | |
| 788 | + } | |
| 789 | + if (model.pageStyleList.count>0) { | |
| 790 | + self.topBgImg.frame = CGRectMake(0, 0, KScreenWidth, self.topBgImgHeight); | |
| 791 | + CNLiveSubSegmentController *subVC = [[CNLiveSubSegmentController alloc] initWithModel:model]; | |
| 792 | + subVC.isBlack = isBlack; | |
| 793 | + subVC.delegate = self; | |
| 794 | + if (index == self.isLoginIndex) { | |
| 795 | + subVC.selectChannelId = index; | |
| 796 | + } | |
| 797 | + weakself | |
| 798 | + subVC.scrollViewDidScrollBlock = ^(BOOL isUp) { | |
| 799 | + [weakSelf scrollViewUpDowm:isUp]; | |
| 800 | + }; | |
| 801 | + return subVC; | |
| 811 | 802 | |
| 803 | + } | |
| 804 | + self.topBgImg.frame = CGRectMake(0, 0, KScreenWidth, self.topBgImgHeight - 50); | |
| 805 | + return [[CNLiveListController alloc] initWithModel:model black:isBlack bgImage:self.bgImages[index] bgColor:model.backgroundColor bgImageH5:model.backgroundImgH5]; | |
| 806 | +} | |
| 812 | 807 | #pragma mark - JXCategoryViewDelegate |
| 813 | 808 | - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index { |
| 814 | 809 | NSLog(@"%@", NSStringFromSelector(_cmd)); |
| 815 | - UIViewController *vc = self.controllersArr[index]; | |
| 816 | - vc.navigationController.navigationBarHidden = YES; | |
| 817 | - if (index>self.ld_currentIndex) { | |
| 818 | - [self.pageViewController setViewControllers:@[vc] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL]; | |
| 819 | - }else | |
| 820 | - { | |
| 821 | - [self.pageViewController setViewControllers:@[vc] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:NULL]; | |
| 822 | - } | |
| 823 | 810 | // 侧滑手势处理 |
| 824 | 811 | self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0); |
| 825 | 812 | [self updateSelectColors:index]; |
| ... | ... | @@ -829,7 +816,7 @@ static CGFloat moveHeight = 50; |
| 829 | 816 | [BHConfig set:ChannelsSelectFirst value:model.id]; |
| 830 | 817 | } |
| 831 | 818 | if (model.pageStyleList.count>0) { |
| 832 | - CNLiveSubSegmentController *subVC = (CNLiveSubSegmentController *)self.controllersArr[index]; | |
| 819 | + CNLiveSubSegmentController *subVC = (CNLiveSubSegmentController *)self.listContainerView.validListDict[@(index)]; | |
| 833 | 820 | if (subVC && [subVC respondsToSelector:@selector(refreshCurrentVCData)]) { |
| 834 | 821 | [subVC refreshCurrentVCData]; |
| 835 | 822 | } |
| ... | ... | @@ -862,7 +849,7 @@ static CGFloat moveHeight = 50; |
| 862 | 849 | if ([model.id isEqualToString:@"1"]) { |
| 863 | 850 | time = 60; |
| 864 | 851 | } |
| 865 | - [CNLiveClassifyJumpBridge listViewRefreshWithVC:self.controllersArr[index] pageType:model.pageType.integerValue param:paramDic refreshTime:time]; | |
| 852 | + [CNLiveClassifyJumpBridge listViewRefreshWithVC:self.listContainerView.viewController pageType:model.pageType.integerValue param:paramDic refreshTime:time]; | |
| 866 | 853 | } |
| 867 | 854 | if (index != self.myCategoryView.selectedIndex) { |
| 868 | 855 | [[NSNotificationCenter defaultCenter] postNotificationName:WjjH5StopVideoPlayerNotification object:nil]; | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/CNLiveListController.h
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveListController.h | |
| 3 | +// CNLiveVideoClassifyKit | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/9/30. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import <UIKit/UIKit.h> | |
| 9 | +#import "CNCategoryGetChannelModel.h" | |
| 10 | + | |
| 11 | +NS_ASSUME_NONNULL_BEGIN | |
| 12 | + | |
| 13 | +@interface CNLiveListController : UIViewController<JXCategoryListContentViewDelegate> | |
| 14 | +-(instancetype)initWithModel:(CNCategoryGetChannelModel *)model black:(BOOL)black bgImage:(NSString *)bgImage bgColor:(NSString *)bgColor bgImageH5:(NSString *)bgImageH5; | |
| 15 | +@end | |
| 16 | + | |
| 17 | +NS_ASSUME_NONNULL_END | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/CNLiveListController.m
0 → 100644
| 1 | +// | |
| 2 | +// CNLiveListController.m | |
| 3 | +// CNLiveVideoClassifyKit | |
| 4 | +// | |
| 5 | +// Created by CNLive on 2021/9/30. | |
| 6 | +// | |
| 7 | + | |
| 8 | +#import "CNLiveListController.h" | |
| 9 | + | |
| 10 | +@interface CNLiveListController () | |
| 11 | +@property (nonatomic, strong)NSDictionary * paramDic; | |
| 12 | +@property (nonatomic, strong)CNCategoryGetChannelModel *model; | |
| 13 | +@end | |
| 14 | + | |
| 15 | +@implementation CNLiveListController | |
| 16 | +-(instancetype)initWithModel:(CNCategoryGetChannelModel *)model black:(BOOL)black bgImage:(NSString *)bgImage bgColor:(NSString *)bgColor bgImageH5:(NSString *)bgImageH5 | |
| 17 | +{ | |
| 18 | + if (self = [super init]) { | |
| 19 | + _model = model; | |
| 20 | + if ([model.pageType isEqualToString:@"4"] || [model.pageType isEqualToString:@"5"]){ | |
| 21 | + self.paramDic= @{ | |
| 22 | + @"title": model.showName?model.showName:@"", | |
| 23 | + @"bgColor": bgColor?bgColor:@"", | |
| 24 | + @"isBlack":@(black), | |
| 25 | + @"backgroundImg": bgImage?bgImage:@"", | |
| 26 | + @"channelId":model.channelId?model.channelId:@"", | |
| 27 | + @"channelName":model.id?model.id:@"", | |
| 28 | + @"pageId":model.pageId?model.pageId:@"" | |
| 29 | + | |
| 30 | + }; | |
| 31 | + }else{ | |
| 32 | + self.paramDic= @{ | |
| 33 | + @"title": model.showName?model.showName:@"", | |
| 34 | + @"bgColor": bgColor?bgColor:@"", | |
| 35 | + @"isBlack":@(black), | |
| 36 | + @"thirdUrl":model.thirdUrl?model.thirdUrl:@"", | |
| 37 | + @"backgroundImgH5":bgImageH5?bgImageH5:@"" | |
| 38 | + }; | |
| 39 | + } | |
| 40 | + } | |
| 41 | + return self; | |
| 42 | +} | |
| 43 | +- (void)viewDidLoad { | |
| 44 | + [super viewDidLoad]; | |
| 45 | + UIViewController *subVC = [CNLiveClassifyJumpBridge ListViewWithPageType:_model.pageType.integerValue param:_paramDic]; | |
| 46 | + [self.view addSubview:subVC.view]; | |
| 47 | + [self addChildViewController:subVC]; | |
| 48 | + [subVC didMoveToParentViewController:self]; | |
| 49 | + // Do any additional setup after loading the view. | |
| 50 | +} | |
| 51 | +-(void)viewDidLayoutSubviews | |
| 52 | +{ | |
| 53 | + [super viewDidLayoutSubviews]; | |
| 54 | +} | |
| 55 | +#pragma mark - JXCategoryListContentViewDelegate | |
| 56 | +-(UIView *)listView | |
| 57 | +{ | |
| 58 | + return self.view; | |
| 59 | +} | |
| 60 | +/* | |
| 61 | +#pragma mark - Navigation | |
| 62 | + | |
| 63 | +// In a storyboard-based application, you will often want to do a little preparation before navigation | |
| 64 | +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
| 65 | + // Get the new view controller using [segue destinationViewController]. | |
| 66 | + // Pass the selected object to the new view controller. | |
| 67 | +} | |
| 68 | +*/ | |
| 69 | + | |
| 70 | +@end | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/CNLiveSubSegmentController.h
| ... | ... | @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN |
| 16 | 16 | @end |
| 17 | 17 | |
| 18 | 18 | |
| 19 | -@interface CNLiveSubSegmentController : CNCategoryBaseViewController | |
| 19 | +@interface CNLiveSubSegmentController : CNCategoryBaseViewController<JXCategoryListContentViewDelegate> | |
| 20 | 20 | |
| 21 | 21 | @property (nonatomic, assign) BOOL isBlack; |
| 22 | 22 | @property (nonatomic, assign) NSInteger selectChannelId; | ... | ... |
CNLiveVideoClassifyKit/Classes/Controller/CNLiveSubSegmentController.m
| ... | ... | @@ -8,6 +8,7 @@ |
| 8 | 8 | #import "CNLiveSubSegmentController.h" |
| 9 | 9 | #import "CNAudioPlayProgressView.h" |
| 10 | 10 | #import "CNLiveListManager.h" |
| 11 | +#import "CNLiveListController.h" | |
| 11 | 12 | |
| 12 | 13 | @interface CNLiveSubSegmentController () |
| 13 | 14 | @property (nonatomic, strong)JXCategoryTitleView *myCategoryView; |
| ... | ... | @@ -97,7 +98,7 @@ |
| 97 | 98 | // 添加二级频道右侧的搜索按钮 |
| 98 | 99 | [self.view addSubview:self.searchBtn]; |
| 99 | 100 | self.view.backgroundColor = [UIColor clearColor]; |
| 100 | - self.findScrollView.scrollEnabled = NO; | |
| 101 | + self.listContainerView.scrollView.scrollEnabled = NO; | |
| 101 | 102 | self.myCategoryView.titles = self.titles; |
| 102 | 103 | if (CNLiveStringIsEmpty(self.backImage)) { |
| 103 | 104 | self.view.backgroundColor = CNLiveColorWithHexString(self.backgroundColor); |
| ... | ... | @@ -114,20 +115,6 @@ |
| 114 | 115 | self.myCategoryView.indicators = @[lineView]; |
| 115 | 116 | [self.categoryView reloadData]; |
| 116 | 117 | |
| 117 | - for (int i = 0; i<self.titles.count; i++) { | |
| 118 | - CNCategoryGetChannelModel *model = self.pageListArr[i]; | |
| 119 | - CNLiveListManager *list = [CNLiveListManager shareListManager]; | |
| 120 | - UIViewController *listVC = [list model:model black:_isBlack bgImage:self.backImage bgColor:self.backgroundColor bgImageH5:self.backImageH5]; | |
| 121 | - | |
| 122 | - weakself | |
| 123 | - list.scrollViewDidScrollBlock = ^(BOOL isUp) { | |
| 124 | - !weakSelf.scrollViewDidScrollBlock ?: weakSelf.scrollViewDidScrollBlock(isUp); | |
| 125 | - [weakSelf rightSubViewWithShow:isUp]; | |
| 126 | - }; | |
| 127 | - [self.controllersArr addObject:listVC]; | |
| 128 | - } | |
| 129 | - [self addTheFirstPage]; | |
| 130 | - | |
| 131 | 118 | if ([self.channelId isEqualToString:@"219"]) { |
| 132 | 119 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePlayingStatus:) name:WjjAudioPlayerStatusNotification object:nil]; |
| 133 | 120 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePlayingSchedule:) name:WjjAudioPlayerScheduleNotification object:nil]; |
| ... | ... | @@ -169,7 +156,6 @@ |
| 169 | 156 | } |
| 170 | 157 | |
| 171 | 158 | self.myCategoryView.top = 0; |
| 172 | - self.pageViewController.view.frame = CGRectMake(0, self.myCategoryView.bottom+10, kScreenWidth, self.view.bounds.size.height - self.myCategoryView.bottom); | |
| 173 | 159 | self.searchBtn.right = KScreenWidth-12; |
| 174 | 160 | CGFloat width = self.searchBtn.left; |
| 175 | 161 | self.searchBtn.centerY = self.myCategoryView.height/2; |
| ... | ... | @@ -185,13 +171,18 @@ |
| 185 | 171 | width = self.historyBtn.left; |
| 186 | 172 | } |
| 187 | 173 | self.myCategoryView.width = width; |
| 174 | + weakself | |
| 175 | + [CNLiveListManager shareListManager].scrollViewDidScrollBlock = ^(BOOL isUp) { | |
| 176 | + !self.scrollViewDidScrollBlock ?: self.scrollViewDidScrollBlock(isUp); | |
| 177 | + [weakSelf rightSubViewWithShow:isUp]; | |
| 178 | + }; | |
| 188 | 179 | // Do any additional setup after loading the view. |
| 189 | 180 | } |
| 190 | 181 | -(void)viewDidLayoutSubviews |
| 191 | 182 | { |
| 192 | 183 | [super viewDidLayoutSubviews]; |
| 193 | 184 | self.myCategoryView.top = 0; |
| 194 | - self.pageViewController.view.frame = CGRectMake(0, self.myCategoryView.bottom+10, kScreenWidth, self.view.bounds.size.height - self.myCategoryView.bottom); | |
| 185 | + self.listContainerView.frame = CGRectMake(0, self.myCategoryView.bottom+10, kScreenWidth, self.view.bounds.size.height - self.myCategoryView.bottom); | |
| 195 | 186 | self.searchBtn.right = KScreenWidth-12; |
| 196 | 187 | CGFloat width = self.searchBtn.left; |
| 197 | 188 | self.searchBtn.centerY = self.myCategoryView.height/2; |
| ... | ... | @@ -308,10 +299,10 @@ |
| 308 | 299 | } |
| 309 | 300 | // 一级频道显示隐藏时二级频道右侧的搜索按钮变宽变窄控制 |
| 310 | 301 | - (void)rightSubViewWithShow:(BOOL)show { |
| 311 | - if (show == self.findScrollView.isScrollEnabled) { | |
| 302 | + if (show == self.listContainerView.scrollView.isScrollEnabled) { | |
| 312 | 303 | return; |
| 313 | 304 | } |
| 314 | - self.findScrollView.scrollEnabled = show; | |
| 305 | + self.listContainerView.scrollView.scrollEnabled = show; | |
| 315 | 306 | self.isHiddenFirst = show; |
| 316 | 307 | weakself |
| 317 | 308 | [UIView animateWithDuration:0.3 animations:^{ |
| ... | ... | @@ -382,7 +373,7 @@ |
| 382 | 373 | if ([model.id isEqualToString:@"1"]) { |
| 383 | 374 | time = 60; |
| 384 | 375 | } |
| 385 | - [CNLiveClassifyJumpBridge listViewRefreshWithVC:self.controllersArr[self.ld_currentIndex] pageType:model.pageType.integerValue param:paramDic refreshTime:time]; | |
| 376 | + [CNLiveClassifyJumpBridge listViewRefreshWithVC:self.listContainerView.viewController pageType:model.pageType.integerValue param:paramDic refreshTime:time]; | |
| 386 | 377 | } |
| 387 | 378 | -(void)showGuideView |
| 388 | 379 | { |
| ... | ... | @@ -513,22 +504,26 @@ |
| 513 | 504 | { |
| 514 | 505 | return 40; |
| 515 | 506 | } |
| 507 | +#pragma mark - JXCategoryListContainerViewDelegate | |
| 508 | +- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{ | |
| 509 | + CNCategoryGetChannelModel *model = self.pageListArr[index]; | |
| 510 | + return [[CNLiveListController alloc] initWithModel:model black:_isBlack bgImage:self.backImage bgColor:self.backgroundColor bgImageH5:self.backImageH5]; | |
| 511 | +} | |
| 512 | +#pragma mark - JXCategoryListContentViewDelegate | |
| 513 | +-(UIView *)listView | |
| 514 | +{ | |
| 515 | + return self.view; | |
| 516 | +} | |
| 516 | 517 | #pragma mark - JXCategoryViewDelegate |
| 517 | --(void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index | |
| 518 | +- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index | |
| 518 | 519 | { |
| 519 | 520 | self.navigationController.interactivePopGestureRecognizer.enabled = (index ==0); |
| 520 | 521 | self.myCategoryView.defaultSelectedIndex = index; |
| 521 | - UIViewController *vc = self.controllersArr[index]; | |
| 522 | - if (index>self.ld_currentIndex) { | |
| 523 | - [self.pageViewController setViewControllers:@[vc] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL]; | |
| 524 | - }else | |
| 525 | - { | |
| 526 | 522 | self.ld_currentIndex = index; |
| 527 | 523 | if (index != self.myCategoryView.selectedIndex) { |
| 528 | 524 | [[NSNotificationCenter defaultCenter] postNotificationName:WjjH5StopVideoPlayerNotification object:nil]; |
| 529 | 525 | [[NSNotificationCenter defaultCenter] postNotificationName:kDSHappinessPageControlScrollEnableNotification object:@(YES)]; |
| 530 | 526 | } |
| 531 | - [self.pageViewController setViewControllers:@[vc] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:NULL]; | |
| 532 | 527 | CNCategoryGetChannelModel *model = (CNCategoryGetChannelModel *)[self.pageListArr safetyObjectAtIndex:index]; |
| 533 | 528 | if (![CNUserShareManager isLogin]) { |
| 534 | 529 | [BHConfig set:ChannelsSelectSecond value:model.id]; |
| ... | ... | @@ -552,7 +547,7 @@ |
| 552 | 547 | if ([model.id isEqualToString:@"1"]) { |
| 553 | 548 | time = 60; |
| 554 | 549 | } |
| 555 | - [CNLiveClassifyJumpBridge listViewRefreshWithVC:self.controllersArr[index] pageType:model.pageType.integerValue param:paramDic refreshTime:time]; | |
| 550 | + [CNLiveClassifyJumpBridge listViewRefreshWithVC:self.listContainerView.viewController pageType:model.pageType.integerValue param:paramDic refreshTime:time]; | |
| 556 | 551 | [self showGuideView]; |
| 557 | 552 | weakself |
| 558 | 553 | [self.bgImgView sd_setImageWithURL:[NSURL URLWithString:self.backImageH5] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { |
| ... | ... | @@ -560,7 +555,6 @@ |
| 560 | 555 | weakSelf.bgImgView.height = KScreenWidth*image.size.height/image.size.width; |
| 561 | 556 | } |
| 562 | 557 | }]; |
| 563 | - } | |
| 564 | 558 | } |
| 565 | 559 | #pragma mark - Getting&&Setting |
| 566 | 560 | -(JXCategoryTitleView *)myCategoryView | ... | ... |
CNLiveVideoClassifyKit/Classes/Manager/CNLiveListManager.h
| ... | ... | @@ -11,11 +11,10 @@ NS_ASSUME_NONNULL_BEGIN |
| 11 | 11 | |
| 12 | 12 | @interface CNLiveListManager : NSObject |
| 13 | 13 | @property (nonatomic, copy) void (^scrollViewDidScrollBlock)(BOOL isUp); |
| 14 | +@property (nonatomic, assign) BOOL isHiddenFirst; | |
| 14 | 15 | |
| 15 | 16 | +(instancetype)shareListManager; |
| 16 | 17 | |
| 17 | --(UIViewController *)model:(CNCategoryGetChannelModel *)model black:(BOOL)black bgImage:(NSString *)bgImage bgColor:(NSString *)bgColor bgImageH5:(NSString *)bgImageH5; | |
| 18 | - | |
| 19 | 18 | - (void)requestWebViewForScrollView:(nonnull UIScrollView *)scrollView isBeginDragging:(BOOL)isBeginDragging; |
| 20 | 19 | |
| 21 | 20 | + (CNCategoryBaseViewController *)CNCategoryBaseViewController; | ... | ... |
CNLiveVideoClassifyKit/Classes/Manager/CNLiveListManager.m
| ... | ... | @@ -29,42 +29,22 @@ |
| 29 | 29 | { |
| 30 | 30 | return [[CNLiveClassifySegmentController alloc] init]; |
| 31 | 31 | } |
| 32 | - | |
| 33 | --(UIViewController *)model:(CNCategoryGetChannelModel *)model black:(BOOL)black bgImage:(NSString *)bgImage bgColor:(nonnull NSString *)bgColor bgImageH5:(nonnull NSString *)bgImageH5 | |
| 34 | -{ | |
| 35 | - NSDictionary * paramDic = nil; | |
| 36 | - if ([model.pageType isEqualToString:@"4"] || [model.pageType isEqualToString:@"5"]){ | |
| 37 | - paramDic= @{ | |
| 38 | - @"title": model.showName?model.showName:@"", | |
| 39 | - @"bgColor": bgColor?bgColor:@"", | |
| 40 | - @"isBlack":@(black), | |
| 41 | - @"backgroundImg": bgImage?bgImage:@"", | |
| 42 | - @"channelId":model.channelId?model.channelId:@"", | |
| 43 | - @"channelName":model.id?model.id:@"", | |
| 44 | - @"pageId":model.pageId?model.pageId:@"" | |
| 45 | - | |
| 46 | - }; | |
| 47 | - }else{ | |
| 48 | - paramDic= @{ | |
| 49 | - @"title": model.showName?model.showName:@"", | |
| 50 | - @"bgColor": bgColor?bgColor:@"", | |
| 51 | - @"isBlack":@(black), | |
| 52 | - @"thirdUrl":model.thirdUrl?model.thirdUrl:@"", | |
| 53 | - @"backgroundImgH5":bgImageH5?bgImageH5:@"" | |
| 54 | - }; | |
| 55 | - } | |
| 56 | - UIViewController *subVC = [CNLiveClassifyJumpBridge ListViewWithPageType:model.pageType.integerValue param:paramDic]; | |
| 57 | - return subVC; | |
| 58 | -} | |
| 59 | 32 | - (void)requestWebViewForScrollView:(nonnull UIScrollView *)scrollView isBeginDragging:(BOOL)isBeginDragging |
| 60 | 33 | { |
| 61 | 34 | if (isBeginDragging) { |
| 62 | 35 | beginoffsetY = scrollView.offsetY; |
| 63 | 36 | }else |
| 64 | 37 | { |
| 65 | - if (scrollView.offsetY - beginoffsetY>5) { | |
| 38 | + CGFloat hight = scrollView.frame.size.height; | |
| 39 | + CGFloat contentOffset = scrollView.contentOffset.y; | |
| 40 | + CGFloat distanceFromBottom = scrollView.contentSize.height - contentOffset; | |
| 41 | + CGFloat offset = contentOffset - beginoffsetY; | |
| 42 | + beginoffsetY = contentOffset; | |
| 43 | + if (offset > 0 && contentOffset > 0 && !self.isHiddenFirst) { | |
| 44 | + self.isHiddenFirst = YES; | |
| 66 | 45 | !self.scrollViewDidScrollBlock ?: self.scrollViewDidScrollBlock(YES); |
| 67 | - }else if (scrollView.offsetY - beginoffsetY<0) { | |
| 46 | + }else if (offset < 0 && ((scrollView.contentSize.height<hight && contentOffset<0) || distanceFromBottom>hight+1) && self.isHiddenFirst) { | |
| 47 | + self.isHiddenFirst = NO; | |
| 68 | 48 | !self.scrollViewDidScrollBlock ?: self.scrollViewDidScrollBlock(NO); |
| 69 | 49 | } |
| 70 | 50 | } | ... | ... |