Commit f8bb5a7095ee1b9b2546ce4cebd454f6a41c9e4e

Authored by yanglingyu
1 parent a9e1d481

no message

CNLiveVideoClassifyKit/Classes/ClassifyCategory/Controller/CNLiveListController.m
... ... @@ -60,9 +60,9 @@
60 60 [CNLiveClassifyJumpBridge listViewRefreshWithVC:subVC pageType:_model.pageType.integerValue param:_paramDic refreshTime:time];
61 61 // Do any additional setup after loading the view.
62 62 }
63   -- (void)viewDidAppear:(BOOL)animated
  63 +- (void)viewWillAppear:(BOOL)animated
64 64 {
65   - [super viewDidAppear:animated];
  65 + [super viewWillAppear:animated];
66 66 NSLog(@"%@",self.childViewControllers[0]);
67 67 UIViewController *vc = self.childViewControllers[0];
68 68 if (([CNLiveListController searchProperties:[vc class] string:@"webView"]||[CNLiveListController searchProperties:[vc.superclass class] string:@"webView"])&&[vc valueForKey:@"webView"]&&[[vc valueForKey:@"webView"] isKindOfClass:[WKWebView class]]) {
... ... @@ -88,27 +88,19 @@
88 88 UIViewController *vc = self.childViewControllers[0];
89 89 if (([CNLiveListController searchProperties:[vc class] string:@"webView"]||[CNLiveListController searchProperties:[vc.superclass class] string:@"webView"])&&[vc valueForKey:@"webView"]&&[[vc valueForKey:@"webView"] isKindOfClass:[WKWebView class]]) {
90 90 WKWebView *webView = (WKWebView *)[vc valueForKey:@"webView"];
91   - if ([self isObj:webView.scrollView hasObserverKey:@"contentOffset"]) {
92 91 [webView.scrollView removeObserver:self forKeyPath:@"contentOffset"];
93   - }
94 92  
95 93 if ([webView.scrollView valueForKey:@"mj_header"]) {
96 94 id header = [webView.scrollView valueForKey:@"mj_header"];
97   - if ([self isObj:header hasObserverKey:@"state"]) {
98 95 [header removeObserver:self forKeyPath:@"state"];
99   - }
100 96 }
101 97  
102 98 }else if ([CNLiveListController searchProperties:[vc class] string:@"collectionView"]&&[vc valueForKey:@"collectionView"] && [[vc valueForKey:@"collectionView"] isKindOfClass:[UICollectionView class]]){
103 99 UICollectionView *collectionView = (UICollectionView *)[vc valueForKey:@"collectionView"];
104   - if ([self isObj:collectionView hasObserverKey:@"contentOffset"]) {
105 100 [collectionView removeObserver:self forKeyPath:@"contentOffset"];
106   - }
107 101 if ([collectionView valueForKey:@"mj_header"]) {
108 102 id header = [collectionView valueForKey:@"mj_header"];
109   - if ([self isObj:header hasObserverKey:@"state"]) {
110 103 [header removeObserver:self forKeyPath:@"state"];
111   - }
112 104 }
113 105 }
114 106 }
... ... @@ -126,25 +118,6 @@
126 118 }
127 119 return NO;
128 120 }
129   --(BOOL)isObj:(NSObject *)obj hasObserverKey:(NSString *)keyPath{
130   - if (obj == nil) {
131   - return NO;
132   - }
133   - if (obj.observationInfo == nil) {
134   - return NO;
135   - }
136   - NSObject *observances = [((__bridge NSObject*)(obj.observationInfo))valueForKeyPath:@"observances"];
137   - if ([observances isKindOfClass:[NSArray class]]) {
138   - for (NSObject *observance in (NSArray *)observances) {
139   - NSString *inKeyPath = [NSString stringWithFormat:@"Key path: %@",keyPath];
140   - NSString *objString = [NSString stringWithFormat:@"%@",observance];
141   - if ([objString containsString:inKeyPath]) {
142   - return YES;
143   - }
144   - }
145   - }
146   - return NO;
147   -}
148 121 #pragma mark - KVO
149 122 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
150 123 {
... ...