美文网首页
计算wkwebview实际高度

计算wkwebview实际高度

作者: 被风吹乱的思念 | 来源:发表于2018-05-22 10:52 被阅读14次
    - (void)viewDidLoad
    {
        [self.webView.scrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil];
    }
    
    - (void)dealloc {
        
        [self.webView.scrollView removeObserver:self forKeyPath:@"contentSize" context:nil];
    }
    
    - (void)observeValueForKeyPath:(NSString *)keyPath
                          ofObject:(id)object
                            change:(NSDictionary *)change
                           context:(void *)context
    {
        if (object == self.webView.scrollView && [keyPath isEqual:@"contentSize"]) {
            // we are here because the contentSize of the WebView's scrollview changed.
            
            UIScrollView *scrollView = self.webView.scrollView;
            NSLog(@"New contentSize: %f x %f", scrollView.contentSize.width, scrollView.contentSize.height);
        }
    }
    

    相关文章

      网友评论

          本文标题:计算wkwebview实际高度

          本文链接:https://www.haomeiwen.com/subject/kekhjftx.html