Commit 65625927db1676575cdc6cb48bac77c23b9f2507

Authored by yanglingyu
1 parent f6e4752a

UIpageController 不好控制scroll的滑动效果,替换ContaintView

CNLiveVideoClassifyKit.podspec
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 8
9 Pod::Spec.new do |s| 9 Pod::Spec.new do |s|
10 s.name = 'CNLiveVideoClassifyKit' 10 s.name = 'CNLiveVideoClassifyKit'
11 - s.version = '0.0.10' 11 + s.version = '0.0.11'
12 s.summary = '视讯头部一二级菜单组件' 12 s.summary = '视讯头部一二级菜单组件'
13 13
14 # This description is used to generate tags and improve search results. 14 # This description is used to generate tags and improve search results.
CNLiveVideoClassifyKit/Classes/Controller/CNCategoryBaseViewController.h
@@ -9,20 +9,16 @@ @@ -9,20 +9,16 @@
9 9
10 NS_ASSUME_NONNULL_BEGIN 10 NS_ASSUME_NONNULL_BEGIN
11 11
12 -@interface CNCategoryBaseViewController : UIViewController<JXCategoryViewDelegate,UIPageViewControllerDelegate,UIPageViewControllerDataSource> 12 +@interface CNCategoryBaseViewController : UIViewController<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
13 13
14 @property (nonatomic, strong) JXCategoryBaseView *categoryView; 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 @property (nonatomic, strong) NSMutableArray *titles;//标题 16 @property (nonatomic, strong) NSMutableArray *titles;//标题
18 -@property (nonatomic, strong) NSMutableArray *controllersArr;/// 控制器数组  
19 -  
20 @property (nonatomic, assign) NSInteger ld_currentIndex; //当前选中 17 @property (nonatomic, assign) NSInteger ld_currentIndex; //当前选中
21 18
22 --(void)addTheFirstPage; //默认页  
23 -(JXCategoryBaseView *)preferredCategoryView; 19 -(JXCategoryBaseView *)preferredCategoryView;
24 -(CGFloat)preferredCategoryViewHeight; 20 -(CGFloat)preferredCategoryViewHeight;
25 --(void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index; 21 +- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index;
26 @end 22 @end
27 23
28 NS_ASSUME_NONNULL_END 24 NS_ASSUME_NONNULL_END
CNLiveVideoClassifyKit/Classes/Controller/CNCategoryBaseViewController.m
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 // 分类控制器根类 6 // 分类控制器根类
7 7
8 #import "CNCategoryBaseViewController.h" 8 #import "CNCategoryBaseViewController.h"
  9 +#import "CNLiveListController.h"
9 10
10 @interface CNCategoryBaseViewController () 11 @interface CNCategoryBaseViewController ()
11 @end 12 @end
@@ -15,8 +16,7 @@ @@ -15,8 +16,7 @@
15 - (void)viewDidLoad { 16 - (void)viewDidLoad {
16 [super viewDidLoad]; 17 [super viewDidLoad];
17 [self.view addSubview: self.categoryView]; 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 self.view.backgroundColor = [UIColor whiteColor]; 20 self.view.backgroundColor = [UIColor whiteColor];
21 21
22 // Do any additional setup after loading the view. 22 // Do any additional setup after loading the view.
@@ -27,6 +27,7 @@ @@ -27,6 +27,7 @@
27 [super viewDidLayoutSubviews]; 27 [super viewDidLayoutSubviews];
28 28
29 self.categoryView.frame = CGRectMake(0, kStatusHeight, self.view.bounds.size.width, [self preferredCategoryViewHeight]); 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 -(void)viewWillAppear:(BOOL)animated 32 -(void)viewWillAppear:(BOOL)animated
32 { 33 {
@@ -37,13 +38,7 @@ @@ -37,13 +38,7 @@
37 } 38 }
38 39
39 #pragma mark - Public 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 -(JXCategoryBaseView *)preferredCategoryView{ 42 -(JXCategoryBaseView *)preferredCategoryView{
48 return [[JXCategoryBaseView alloc] init]; 43 return [[JXCategoryBaseView alloc] init];
49 } 44 }
@@ -53,57 +48,19 @@ @@ -53,57 +48,19 @@
53 return 50; 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 #pragma mark - JXCategoryViewDelegate 59 #pragma mark - JXCategoryViewDelegate
95 --(void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index 60 +- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index
96 { 61 {
97 self.navigationController.interactivePopGestureRecognizer.enabled = (index ==0); 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,29 +70,16 @@
113 if (!_categoryView) { 70 if (!_categoryView) {
114 _categoryView = [self preferredCategoryView]; 71 _categoryView = [self preferredCategoryView];
115 _categoryView.delegate = self; 72 _categoryView.delegate = self;
  73 + _categoryView.listContainer = self.listContainerView;
116 } 74 }
117 return _categoryView; 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 -(NSMutableArray *)titles 84 -(NSMutableArray *)titles
141 { 85 {
@@ -145,12 +89,5 @@ return _findScrollView; @@ -145,12 +89,5 @@ return _findScrollView;
145 return _titles; 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 @end 93 @end
CNLiveVideoClassifyKit/Classes/Controller/CNLiveClassifySegmentController.m
@@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
13 #import "CNWebRedirectHandle.h" 13 #import "CNWebRedirectHandle.h"
14 #import "CNWitnessShadeManager.h" 14 #import "CNWitnessShadeManager.h"
15 #import "CNSupervisionGuideViewManager.h" 15 #import "CNSupervisionGuideViewManager.h"
  16 +#import "CNLiveListController.h"
16 17
17 static const CGFloat animationTime = 0.3; 18 static const CGFloat animationTime = 0.3;
18 static const CGFloat animationHeight = 15; 19 static const CGFloat animationHeight = 15;
@@ -116,7 +117,8 @@ static CGFloat moveHeight = 50; @@ -116,7 +117,8 @@ static CGFloat moveHeight = 50;
116 if ([CNWebRedirectHandle manager].isClickedIntegral) { 117 if ([CNWebRedirectHandle manager].isClickedIntegral) {
117 [CNWebRedirectHandle manager].isClickedIntegral = NO; 118 [CNWebRedirectHandle manager].isClickedIntegral = NO;
118 [self categoryView:self.myCategoryView didSelectedItemAtIndex:[CNWebRedirectHandle manager].channelId]; 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 if([svc isKindOfClass:[CNLiveSubSegmentController class]]){ 122 if([svc isKindOfClass:[CNLiveSubSegmentController class]]){
121 //目击者 - 今日要闻 - 中国冰雪 123 //目击者 - 今日要闻 - 中国冰雪
122 [svc categoryView:svc.categoryView didSelectedItemAtIndex:[CNWebRedirectHandle manager].classifyId]; 124 [svc categoryView:svc.categoryView didSelectedItemAtIndex:[CNWebRedirectHandle manager].classifyId];
@@ -168,6 +170,10 @@ static CGFloat moveHeight = 50; @@ -168,6 +170,10 @@ static CGFloat moveHeight = 50;
168 { 170 {
169 [self.view addSubview:self.loginBtn]; 171 [self.view addSubview:self.loginBtn];
170 } 172 }
  173 + weakself
  174 + [CNLiveListManager shareListManager].scrollViewDidScrollBlock = ^(BOOL isUp) {
  175 + [weakSelf scrollViewUpDowm:isUp];
  176 + };
171 // Do any additional setup after loading the view. 177 // Do any additional setup after loading the view.
172 } 178 }
173 -(void)viewWillAppear:(BOOL)animated { 179 -(void)viewWillAppear:(BOOL)animated {
@@ -203,7 +209,7 @@ static CGFloat moveHeight = 50; @@ -203,7 +209,7 @@ static CGFloat moveHeight = 50;
203 -(void)viewDidLayoutSubviews 209 -(void)viewDidLayoutSubviews
204 { 210 {
205 [super viewDidLayoutSubviews]; 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 if ([CNUserShareManager isLogin]) { 213 if ([CNUserShareManager isLogin]) {
208 self.myCategoryView.width = kScreenWidth - 45; 214 self.myCategoryView.width = kScreenWidth - 45;
209 self.customChannelsBtn.centerY = [self preferredCategoryViewHeight]/2 + kStatusHeight; 215 self.customChannelsBtn.centerY = [self preferredCategoryViewHeight]/2 + kStatusHeight;
@@ -247,42 +253,6 @@ static CGFloat moveHeight = 50; @@ -247,42 +253,6 @@ static CGFloat moveHeight = 50;
247 }; 253 };
248 [self updateSelectColors:self.ld_currentIndex]; 254 [self updateSelectColors:self.ld_currentIndex];
249 [self configCategoryViewWithType:JXCategoryTitleImageType_OnlyImage selectIndex:self.ld_currentIndex unselectIndex:self.ld_currentIndex]; 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 self.isLoad = YES; 256 self.isLoad = YES;
287 if (![CNUserShareManager isLogin]) { 257 if (![CNUserShareManager isLogin]) {
288 [CNLiveClassifyJumpBridge bringCenterLoginViewToFront]; 258 [CNLiveClassifyJumpBridge bringCenterLoginViewToFront];
@@ -341,12 +311,12 @@ static CGFloat moveHeight = 50; @@ -341,12 +311,12 @@ static CGFloat moveHeight = 50;
341 311
342 // 电商中国可以下拉出地图页面 当下拉出地图页面时不可以左右滚动 312 // 电商中国可以下拉出地图页面 当下拉出地图页面时不可以左右滚动
343 - (void)PageControlScrollEnable:(NSNotification *)noti { 313 - (void)PageControlScrollEnable:(NSNotification *)noti {
344 - if (!self.findScrollView.isScrollEnabled) { 314 + if (!self.listContainerView.scrollView.isScrollEnabled) {
345 return; 315 return;
346 } 316 }
347 BOOL scrollEnable = [noti.object boolValue]; 317 BOOL scrollEnable = [noti.object boolValue];
348 NSLog(@"是否可滚动:%d",scrollEnable); 318 NSLog(@"是否可滚动:%d",scrollEnable);
349 - self.findScrollView.scrollEnabled = scrollEnable; 319 + self.listContainerView.scrollView.scrollEnabled = scrollEnable;
350 } 320 }
351 321
352 - (void)touristsLoginTipsViewIsClassify:(NSNotification *)noti{ 322 - (void)touristsLoginTipsViewIsClassify:(NSNotification *)noti{
@@ -606,7 +576,6 @@ static CGFloat moveHeight = 50; @@ -606,7 +576,6 @@ static CGFloat moveHeight = 50;
606 [self.textColors removeAllObjects]; 576 [self.textColors removeAllObjects];
607 [self.textColorSeleteds removeAllObjects]; 577 [self.textColorSeleteds removeAllObjects];
608 [self.statusBarColors removeAllObjects]; 578 [self.statusBarColors removeAllObjects];
609 - [self.controllersArr removeAllObjects];  
610 for (NSString *str in normalArray) { 579 for (NSString *str in normalArray) {
611 NSDictionary *dic = CNLiveStringJsonToDictionary(str); 580 NSDictionary *dic = CNLiveStringJsonToDictionary(str);
612 CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic]; 581 CNCategoryGetChannelModel *model = [CNCategoryGetChannelModel mj_objectWithKeyValues:dic];
@@ -658,10 +627,10 @@ static CGFloat moveHeight = 50; @@ -658,10 +627,10 @@ static CGFloat moveHeight = 50;
658 } 627 }
659 -(void)scrollViewUpDowm:(BOOL)isUp 628 -(void)scrollViewUpDowm:(BOOL)isUp
660 { 629 {
661 - if (isUp != self.findScrollView.isScrollEnabled) { 630 + if (isUp != self.listContainerView.scrollView.isScrollEnabled) {
662 return; 631 return;
663 } 632 }
664 - self.findScrollView.scrollEnabled = !isUp; 633 + self.listContainerView.scrollView.scrollEnabled = !isUp;
665 self.isHiddenFirst = isUp; 634 self.isHiddenFirst = isUp;
666 [UIView animateWithDuration:0.3 animations:^{ 635 [UIView animateWithDuration:0.3 animations:^{
667 if (isUp) { 636 if (isUp) {
@@ -676,7 +645,7 @@ static CGFloat moveHeight = 50; @@ -676,7 +645,7 @@ static CGFloat moveHeight = 50;
676 -(void)scrollViewUp{ 645 -(void)scrollViewUp{
677 self.topBgImg.top -= moveHeight; 646 self.topBgImg.top -= moveHeight;
678 self.myCategoryView.collectionView.top = -50-kStatusHeight; 647 self.myCategoryView.collectionView.top = -50-kStatusHeight;
679 - self.pageViewController.view.top = kStatusHeight; 648 + self.listContainerView.top = kStatusHeight;
680 if ([CNUserShareManager isLogin]) { 649 if ([CNUserShareManager isLogin]) {
681 self.customChannelsBtn.centerY = self.myCategoryView.collectionView.centerY + kStatusHeight; 650 self.customChannelsBtn.centerY = self.myCategoryView.collectionView.centerY + kStatusHeight;
682 }else 651 }else
@@ -687,7 +656,7 @@ static CGFloat moveHeight = 50; @@ -687,7 +656,7 @@ static CGFloat moveHeight = 50;
687 -(void)scrollViewDown{ 656 -(void)scrollViewDown{
688 self.topBgImg.top += moveHeight; 657 self.topBgImg.top += moveHeight;
689 self.myCategoryView.collectionView.top = 0; 658 self.myCategoryView.collectionView.top = 0;
690 - self.pageViewController.view.top = self.myCategoryView.bottom; 659 + self.listContainerView.top = self.myCategoryView.bottom;
691 if ([CNUserShareManager isLogin]) { 660 if ([CNUserShareManager isLogin]) {
692 self.customChannelsBtn.centerY = self.myCategoryView.centerY; 661 self.customChannelsBtn.centerY = self.myCategoryView.centerY;
693 }else 662 }else
@@ -808,18 +777,36 @@ static CGFloat moveHeight = 50; @@ -808,18 +777,36 @@ static CGFloat moveHeight = 50;
808 self.customChannelsV = nil; 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 #pragma mark - JXCategoryViewDelegate 807 #pragma mark - JXCategoryViewDelegate
813 - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index { 808 - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
814 NSLog(@"%@", NSStringFromSelector(_cmd)); 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 self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0); 811 self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
825 [self updateSelectColors:index]; 812 [self updateSelectColors:index];
@@ -829,7 +816,7 @@ static CGFloat moveHeight = 50; @@ -829,7 +816,7 @@ static CGFloat moveHeight = 50;
829 [BHConfig set:ChannelsSelectFirst value:model.id]; 816 [BHConfig set:ChannelsSelectFirst value:model.id];
830 } 817 }
831 if (model.pageStyleList.count>0) { 818 if (model.pageStyleList.count>0) {
832 - CNLiveSubSegmentController *subVC = (CNLiveSubSegmentController *)self.controllersArr[index]; 819 + CNLiveSubSegmentController *subVC = (CNLiveSubSegmentController *)self.listContainerView.validListDict[@(index)];
833 if (subVC && [subVC respondsToSelector:@selector(refreshCurrentVCData)]) { 820 if (subVC && [subVC respondsToSelector:@selector(refreshCurrentVCData)]) {
834 [subVC refreshCurrentVCData]; 821 [subVC refreshCurrentVCData];
835 } 822 }
@@ -862,7 +849,7 @@ static CGFloat moveHeight = 50; @@ -862,7 +849,7 @@ static CGFloat moveHeight = 50;
862 if ([model.id isEqualToString:@"1"]) { 849 if ([model.id isEqualToString:@"1"]) {
863 time = 60; 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 if (index != self.myCategoryView.selectedIndex) { 854 if (index != self.myCategoryView.selectedIndex) {
868 [[NSNotificationCenter defaultCenter] postNotificationName:WjjH5StopVideoPlayerNotification object:nil]; 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,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
16 @end 16 @end
17 17
18 18
19 -@interface CNLiveSubSegmentController : CNCategoryBaseViewController 19 +@interface CNLiveSubSegmentController : CNCategoryBaseViewController<JXCategoryListContentViewDelegate>
20 20
21 @property (nonatomic, assign) BOOL isBlack; 21 @property (nonatomic, assign) BOOL isBlack;
22 @property (nonatomic, assign) NSInteger selectChannelId; 22 @property (nonatomic, assign) NSInteger selectChannelId;
CNLiveVideoClassifyKit/Classes/Controller/CNLiveSubSegmentController.m
@@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
8 #import "CNLiveSubSegmentController.h" 8 #import "CNLiveSubSegmentController.h"
9 #import "CNAudioPlayProgressView.h" 9 #import "CNAudioPlayProgressView.h"
10 #import "CNLiveListManager.h" 10 #import "CNLiveListManager.h"
  11 +#import "CNLiveListController.h"
11 12
12 @interface CNLiveSubSegmentController () 13 @interface CNLiveSubSegmentController ()
13 @property (nonatomic, strong)JXCategoryTitleView *myCategoryView; 14 @property (nonatomic, strong)JXCategoryTitleView *myCategoryView;
@@ -97,7 +98,7 @@ @@ -97,7 +98,7 @@
97 // 添加二级频道右侧的搜索按钮 98 // 添加二级频道右侧的搜索按钮
98 [self.view addSubview:self.searchBtn]; 99 [self.view addSubview:self.searchBtn];
99 self.view.backgroundColor = [UIColor clearColor]; 100 self.view.backgroundColor = [UIColor clearColor];
100 - self.findScrollView.scrollEnabled = NO; 101 + self.listContainerView.scrollView.scrollEnabled = NO;
101 self.myCategoryView.titles = self.titles; 102 self.myCategoryView.titles = self.titles;
102 if (CNLiveStringIsEmpty(self.backImage)) { 103 if (CNLiveStringIsEmpty(self.backImage)) {
103 self.view.backgroundColor = CNLiveColorWithHexString(self.backgroundColor); 104 self.view.backgroundColor = CNLiveColorWithHexString(self.backgroundColor);
@@ -114,20 +115,6 @@ @@ -114,20 +115,6 @@
114 self.myCategoryView.indicators = @[lineView]; 115 self.myCategoryView.indicators = @[lineView];
115 [self.categoryView reloadData]; 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 if ([self.channelId isEqualToString:@"219"]) { 118 if ([self.channelId isEqualToString:@"219"]) {
132 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePlayingStatus:) name:WjjAudioPlayerStatusNotification object:nil]; 119 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePlayingStatus:) name:WjjAudioPlayerStatusNotification object:nil];
133 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePlayingSchedule:) name:WjjAudioPlayerScheduleNotification object:nil]; 120 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePlayingSchedule:) name:WjjAudioPlayerScheduleNotification object:nil];
@@ -169,7 +156,6 @@ @@ -169,7 +156,6 @@
169 } 156 }
170 157
171 self.myCategoryView.top = 0; 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 self.searchBtn.right = KScreenWidth-12; 159 self.searchBtn.right = KScreenWidth-12;
174 CGFloat width = self.searchBtn.left; 160 CGFloat width = self.searchBtn.left;
175 self.searchBtn.centerY = self.myCategoryView.height/2; 161 self.searchBtn.centerY = self.myCategoryView.height/2;
@@ -185,13 +171,18 @@ @@ -185,13 +171,18 @@
185 width = self.historyBtn.left; 171 width = self.historyBtn.left;
186 } 172 }
187 self.myCategoryView.width = width; 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 // Do any additional setup after loading the view. 179 // Do any additional setup after loading the view.
189 } 180 }
190 -(void)viewDidLayoutSubviews 181 -(void)viewDidLayoutSubviews
191 { 182 {
192 [super viewDidLayoutSubviews]; 183 [super viewDidLayoutSubviews];
193 self.myCategoryView.top = 0; 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 self.searchBtn.right = KScreenWidth-12; 186 self.searchBtn.right = KScreenWidth-12;
196 CGFloat width = self.searchBtn.left; 187 CGFloat width = self.searchBtn.left;
197 self.searchBtn.centerY = self.myCategoryView.height/2; 188 self.searchBtn.centerY = self.myCategoryView.height/2;
@@ -308,10 +299,10 @@ @@ -308,10 +299,10 @@
308 } 299 }
309 // 一级频道显示隐藏时二级频道右侧的搜索按钮变宽变窄控制 300 // 一级频道显示隐藏时二级频道右侧的搜索按钮变宽变窄控制
310 - (void)rightSubViewWithShow:(BOOL)show { 301 - (void)rightSubViewWithShow:(BOOL)show {
311 - if (show == self.findScrollView.isScrollEnabled) { 302 + if (show == self.listContainerView.scrollView.isScrollEnabled) {
312 return; 303 return;
313 } 304 }
314 - self.findScrollView.scrollEnabled = show; 305 + self.listContainerView.scrollView.scrollEnabled = show;
315 self.isHiddenFirst = show; 306 self.isHiddenFirst = show;
316 weakself 307 weakself
317 [UIView animateWithDuration:0.3 animations:^{ 308 [UIView animateWithDuration:0.3 animations:^{
@@ -382,7 +373,7 @@ @@ -382,7 +373,7 @@
382 if ([model.id isEqualToString:@"1"]) { 373 if ([model.id isEqualToString:@"1"]) {
383 time = 60; 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 -(void)showGuideView 378 -(void)showGuideView
388 { 379 {
@@ -513,22 +504,26 @@ @@ -513,22 +504,26 @@
513 { 504 {
514 return 40; 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 #pragma mark - JXCategoryViewDelegate 517 #pragma mark - JXCategoryViewDelegate
517 --(void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index 518 +- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index
518 { 519 {
519 self.navigationController.interactivePopGestureRecognizer.enabled = (index ==0); 520 self.navigationController.interactivePopGestureRecognizer.enabled = (index ==0);
520 self.myCategoryView.defaultSelectedIndex = index; 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 self.ld_currentIndex = index; 522 self.ld_currentIndex = index;
527 if (index != self.myCategoryView.selectedIndex) { 523 if (index != self.myCategoryView.selectedIndex) {
528 [[NSNotificationCenter defaultCenter] postNotificationName:WjjH5StopVideoPlayerNotification object:nil]; 524 [[NSNotificationCenter defaultCenter] postNotificationName:WjjH5StopVideoPlayerNotification object:nil];
529 [[NSNotificationCenter defaultCenter] postNotificationName:kDSHappinessPageControlScrollEnableNotification object:@(YES)]; 525 [[NSNotificationCenter defaultCenter] postNotificationName:kDSHappinessPageControlScrollEnableNotification object:@(YES)];
530 } 526 }
531 - [self.pageViewController setViewControllers:@[vc] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:NULL];  
532 CNCategoryGetChannelModel *model = (CNCategoryGetChannelModel *)[self.pageListArr safetyObjectAtIndex:index]; 527 CNCategoryGetChannelModel *model = (CNCategoryGetChannelModel *)[self.pageListArr safetyObjectAtIndex:index];
533 if (![CNUserShareManager isLogin]) { 528 if (![CNUserShareManager isLogin]) {
534 [BHConfig set:ChannelsSelectSecond value:model.id]; 529 [BHConfig set:ChannelsSelectSecond value:model.id];
@@ -552,7 +547,7 @@ @@ -552,7 +547,7 @@
552 if ([model.id isEqualToString:@"1"]) { 547 if ([model.id isEqualToString:@"1"]) {
553 time = 60; 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 [self showGuideView]; 551 [self showGuideView];
557 weakself 552 weakself
558 [self.bgImgView sd_setImageWithURL:[NSURL URLWithString:self.backImageH5] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { 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,7 +555,6 @@
560 weakSelf.bgImgView.height = KScreenWidth*image.size.height/image.size.width; 555 weakSelf.bgImgView.height = KScreenWidth*image.size.height/image.size.width;
561 } 556 }
562 }]; 557 }];
563 - }  
564 } 558 }
565 #pragma mark - Getting&&Setting 559 #pragma mark - Getting&&Setting
566 -(JXCategoryTitleView *)myCategoryView 560 -(JXCategoryTitleView *)myCategoryView
CNLiveVideoClassifyKit/Classes/Manager/CNLiveListManager.h
@@ -11,11 +11,10 @@ NS_ASSUME_NONNULL_BEGIN @@ -11,11 +11,10 @@ NS_ASSUME_NONNULL_BEGIN
11 11
12 @interface CNLiveListManager : NSObject 12 @interface CNLiveListManager : NSObject
13 @property (nonatomic, copy) void (^scrollViewDidScrollBlock)(BOOL isUp); 13 @property (nonatomic, copy) void (^scrollViewDidScrollBlock)(BOOL isUp);
  14 +@property (nonatomic, assign) BOOL isHiddenFirst;
14 15
15 +(instancetype)shareListManager; 16 +(instancetype)shareListManager;
16 17
17 --(UIViewController *)model:(CNCategoryGetChannelModel *)model black:(BOOL)black bgImage:(NSString *)bgImage bgColor:(NSString *)bgColor bgImageH5:(NSString *)bgImageH5;  
18 -  
19 - (void)requestWebViewForScrollView:(nonnull UIScrollView *)scrollView isBeginDragging:(BOOL)isBeginDragging; 18 - (void)requestWebViewForScrollView:(nonnull UIScrollView *)scrollView isBeginDragging:(BOOL)isBeginDragging;
20 19
21 + (CNCategoryBaseViewController *)CNCategoryBaseViewController; 20 + (CNCategoryBaseViewController *)CNCategoryBaseViewController;
CNLiveVideoClassifyKit/Classes/Manager/CNLiveListManager.m
@@ -29,42 +29,22 @@ @@ -29,42 +29,22 @@
29 { 29 {
30 return [[CNLiveClassifySegmentController alloc] init]; 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 - (void)requestWebViewForScrollView:(nonnull UIScrollView *)scrollView isBeginDragging:(BOOL)isBeginDragging 32 - (void)requestWebViewForScrollView:(nonnull UIScrollView *)scrollView isBeginDragging:(BOOL)isBeginDragging
60 { 33 {
61 if (isBeginDragging) { 34 if (isBeginDragging) {
62 beginoffsetY = scrollView.offsetY; 35 beginoffsetY = scrollView.offsetY;
63 }else 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 !self.scrollViewDidScrollBlock ?: self.scrollViewDidScrollBlock(YES); 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 !self.scrollViewDidScrollBlock ?: self.scrollViewDidScrollBlock(NO); 48 !self.scrollViewDidScrollBlock ?: self.scrollViewDidScrollBlock(NO);
69 } 49 }
70 } 50 }