Commit f8bb5a7095ee1b9b2546ce4cebd454f6a41c9e4e
1 parent
a9e1d481
no message
Showing
1 changed file
with
2 additions
and
29 deletions
CNLiveVideoClassifyKit/Classes/ClassifyCategory/Controller/CNLiveListController.m
| @@ -60,9 +60,9 @@ | @@ -60,9 +60,9 @@ | ||
| 60 | [CNLiveClassifyJumpBridge listViewRefreshWithVC:subVC pageType:_model.pageType.integerValue param:_paramDic refreshTime:time]; | 60 | [CNLiveClassifyJumpBridge listViewRefreshWithVC:subVC pageType:_model.pageType.integerValue param:_paramDic refreshTime:time]; |
| 61 | // Do any additional setup after loading the view. | 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 | NSLog(@"%@",self.childViewControllers[0]); | 66 | NSLog(@"%@",self.childViewControllers[0]); |
| 67 | UIViewController *vc = self.childViewControllers[0]; | 67 | UIViewController *vc = self.childViewControllers[0]; |
| 68 | if (([CNLiveListController searchProperties:[vc class] string:@"webView"]||[CNLiveListController searchProperties:[vc.superclass class] string:@"webView"])&&[vc valueForKey:@"webView"]&&[[vc valueForKey:@"webView"] isKindOfClass:[WKWebView class]]) { | 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,27 +88,19 @@ | ||
| 88 | UIViewController *vc = self.childViewControllers[0]; | 88 | UIViewController *vc = self.childViewControllers[0]; |
| 89 | if (([CNLiveListController searchProperties:[vc class] string:@"webView"]||[CNLiveListController searchProperties:[vc.superclass class] string:@"webView"])&&[vc valueForKey:@"webView"]&&[[vc valueForKey:@"webView"] isKindOfClass:[WKWebView class]]) { | 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 | WKWebView *webView = (WKWebView *)[vc valueForKey:@"webView"]; | 90 | WKWebView *webView = (WKWebView *)[vc valueForKey:@"webView"]; |
| 91 | - if ([self isObj:webView.scrollView hasObserverKey:@"contentOffset"]) { | ||
| 92 | [webView.scrollView removeObserver:self forKeyPath:@"contentOffset"]; | 91 | [webView.scrollView removeObserver:self forKeyPath:@"contentOffset"]; |
| 93 | - } | ||
| 94 | 92 | ||
| 95 | if ([webView.scrollView valueForKey:@"mj_header"]) { | 93 | if ([webView.scrollView valueForKey:@"mj_header"]) { |
| 96 | id header = [webView.scrollView valueForKey:@"mj_header"]; | 94 | id header = [webView.scrollView valueForKey:@"mj_header"]; |
| 97 | - if ([self isObj:header hasObserverKey:@"state"]) { | ||
| 98 | [header removeObserver:self forKeyPath:@"state"]; | 95 | [header removeObserver:self forKeyPath:@"state"]; |
| 99 | - } | ||
| 100 | } | 96 | } |
| 101 | 97 | ||
| 102 | }else if ([CNLiveListController searchProperties:[vc class] string:@"collectionView"]&&[vc valueForKey:@"collectionView"] && [[vc valueForKey:@"collectionView"] isKindOfClass:[UICollectionView class]]){ | 98 | }else if ([CNLiveListController searchProperties:[vc class] string:@"collectionView"]&&[vc valueForKey:@"collectionView"] && [[vc valueForKey:@"collectionView"] isKindOfClass:[UICollectionView class]]){ |
| 103 | UICollectionView *collectionView = (UICollectionView *)[vc valueForKey:@"collectionView"]; | 99 | UICollectionView *collectionView = (UICollectionView *)[vc valueForKey:@"collectionView"]; |
| 104 | - if ([self isObj:collectionView hasObserverKey:@"contentOffset"]) { | ||
| 105 | [collectionView removeObserver:self forKeyPath:@"contentOffset"]; | 100 | [collectionView removeObserver:self forKeyPath:@"contentOffset"]; |
| 106 | - } | ||
| 107 | if ([collectionView valueForKey:@"mj_header"]) { | 101 | if ([collectionView valueForKey:@"mj_header"]) { |
| 108 | id header = [collectionView valueForKey:@"mj_header"]; | 102 | id header = [collectionView valueForKey:@"mj_header"]; |
| 109 | - if ([self isObj:header hasObserverKey:@"state"]) { | ||
| 110 | [header removeObserver:self forKeyPath:@"state"]; | 103 | [header removeObserver:self forKeyPath:@"state"]; |
| 111 | - } | ||
| 112 | } | 104 | } |
| 113 | } | 105 | } |
| 114 | } | 106 | } |
| @@ -126,25 +118,6 @@ | @@ -126,25 +118,6 @@ | ||
| 126 | } | 118 | } |
| 127 | return NO; | 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 | #pragma mark - KVO | 121 | #pragma mark - KVO |
| 149 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context | 122 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context |
| 150 | { | 123 | { |