Commit ad5446d8a448e3ca2a82fe85680de763e8fe2b20

Authored by yanglingyu
1 parent 56d2cfa0

修复bug:0092和闪屏问题

CNLiveVideoClassifyKit/Classes/ClassifyCategory/Controller/CNLiveListController.m
... ... @@ -17,6 +17,26 @@
17 17 @end
18 18  
19 19 @implementation CNLiveListController
  20 +- (void)dealloc
  21 +{
  22 + UIViewController *vc = self.childViewControllers[0];
  23 + if (([CNLiveListController searchProperties:[vc class] string:@"webView"]||[CNLiveListController searchProperties:[vc.superclass class] string:@"webView"])&&[vc valueForKey:@"webView"]&&[[vc valueForKey:@"webView"] isKindOfClass:[WKWebView class]]) {
  24 + WKWebView *webView = (WKWebView *)[vc valueForKey:@"webView"];
  25 + [webView.scrollView removeObserver:self forKeyPath:@"contentOffset"];
  26 + if ([webView.scrollView valueForKey:@"mj_header"]) {
  27 + id header = [webView.scrollView valueForKey:@"mj_header"];
  28 + [header removeObserver:self forKeyPath:@"state"];
  29 + }
  30 +
  31 + }else if ([CNLiveListController searchProperties:[vc class] string:@"collectionView"]&&[vc valueForKey:@"collectionView"] && [[vc valueForKey:@"collectionView"] isKindOfClass:[UICollectionView class]]){
  32 + UICollectionView *collectionView = (UICollectionView *)[vc valueForKey:@"collectionView"];
  33 + [collectionView removeObserver:self forKeyPath:@"contentOffset"];
  34 + if ([collectionView valueForKey:@"mj_header"]) {
  35 + id header = [collectionView valueForKey:@"mj_header"];
  36 + [header removeObserver:self forKeyPath:@"state"];
  37 + }
  38 + }
  39 +}
20 40 -(instancetype)initWithModel:(CNCategoryGetChannelModel *)model black:(BOOL)black bgImage:(NSString *)bgImage bgColor:(NSString *)bgColor bgImageH5:(NSString *)bgImageH5
21 41 {
22 42 if (self = [super init]) {
... ... @@ -58,12 +78,6 @@
58 78 [subVC didMoveToParentViewController:self];
59 79 //调用当前vc的刷新功能获取数据
60 80 [CNLiveClassifyJumpBridge listViewRefreshWithVC:subVC pageType:_model.pageType.integerValue param:_paramDic refreshTime:time];
61   - // Do any additional setup after loading the view.
62   -}
63   -- (void)viewWillAppear:(BOOL)animated
64   -{
65   - [super viewWillAppear:animated];
66   - NSLog(@"%@",self.childViewControllers[0]);
67 81 //监听滑动下拉刷新
68 82 UIViewController *vc = self.childViewControllers[0];
69 83 if (([CNLiveListController searchProperties:[vc class] string:@"webView"]||[CNLiveListController searchProperties:[vc.superclass class] string:@"webView"])&&[vc valueForKey:@"webView"]&&[[vc valueForKey:@"webView"] isKindOfClass:[WKWebView class]]) {
... ... @@ -82,29 +96,9 @@
82 96 [header addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionNew context:nil];
83 97 }
84 98 }
  99 + // Do any additional setup after loading the view.
85 100 }
86   -- (void)viewDidDisappear:(BOOL)animated
87   -{
88   - [super viewDidDisappear:animated];
89   - //取消监听
90   - UIViewController *vc = self.childViewControllers[0];
91   - if (([CNLiveListController searchProperties:[vc class] string:@"webView"]||[CNLiveListController searchProperties:[vc.superclass class] string:@"webView"])&&[vc valueForKey:@"webView"]&&[[vc valueForKey:@"webView"] isKindOfClass:[WKWebView class]]) {
92   - WKWebView *webView = (WKWebView *)[vc valueForKey:@"webView"];
93   - [webView.scrollView removeObserver:self forKeyPath:@"contentOffset"];
94   - if ([webView.scrollView valueForKey:@"mj_header"]) {
95   - id header = [webView.scrollView valueForKey:@"mj_header"];
96   - [header removeObserver:self forKeyPath:@"state"];
97   - }
98   -
99   - }else if ([CNLiveListController searchProperties:[vc class] string:@"collectionView"]&&[vc valueForKey:@"collectionView"] && [[vc valueForKey:@"collectionView"] isKindOfClass:[UICollectionView class]]){
100   - UICollectionView *collectionView = (UICollectionView *)[vc valueForKey:@"collectionView"];
101   - [collectionView removeObserver:self forKeyPath:@"contentOffset"];
102   - if ([collectionView valueForKey:@"mj_header"]) {
103   - id header = [collectionView valueForKey:@"mj_header"];
104   - [header removeObserver:self forKeyPath:@"state"];
105   - }
106   - }
107   -}
  101 +
108 102 + (BOOL)searchProperties:(Class)cls string:(NSString *)key
109 103 {
110 104 unsigned int count;
... ... @@ -126,7 +120,7 @@
126 120 if ([keyPath isEqualToString:@"state"]) {
127 121 NSString *state = change[NSKeyValueChangeNewKey];
128 122 if (state.integerValue == 1) {
129   - self.isLoading = NO;
  123 + [self performSelector:@selector(delayAction) afterDelay:1];
130 124 }else{
131 125 self.isLoading = YES;
132 126 }
... ... @@ -150,6 +144,9 @@
150 144 }
151 145 }
152 146 }
  147 +- (void)delayAction{
  148 + self.isLoading = NO;
  149 +}
153 150 #pragma mark - JXCategoryListContentViewDelegate
154 151 -(UIView *)listView
155 152 {
... ...