IOS UIWebView cannot determine the actual height of the web page
@ Interface IndEditorDetailViewController ()
{UIWebView * _ webView; progress * _ progressView; NJKWebViewProgress * _ progressProxy;} @ end @ implementation progress-(void) viewDidLoad {_ progressView = [[UIProgressView alloc] init]; _ progressView. frame = CGRectMake (0, 0,320, 10); [self. view addSubview: _ progressView]; _ progressProxy = [[NJKWebViewProgress alloc] init]; _ webView. delegate = _ progressProxy; _ progressProxy. webViewProxyDelegate = self; _ progressProxy. progressDelegate = self;}-(void) webViewDidFinishLoad :( UIWebView *) webView {// generally, the obtained webpage height will be obtained in this method. // However, the obtained height may not be the actual height of the web page, because the web images are not fully loaded, the web interface may not be real, or the web interface may be long or short. // you may use the following js method to obtain them, but it is useless./** 110000document.doc umentElement. offsetHeight; 2. document. body. clientHeight; 32.16document.doc umentElement. scrollHeight 4, CGRect frame = webView. frame; CGSize fittingSize = [webView sizeThatFits: CGSizeZero]; frame. size = fittingSize; webView. frame = frame; 5. getBodyHeight () // Method 6. CGFloat height = [[webView stringByEvaluatingJavaScriptFromString: @ "document. body. clientHeight "] floatValue, to determine the web height // find a tool on the Internet NJKWebViewProgress} # pragma mark-NJKWebViewProgressDelegate-(void) webViewProgress :( NJKWebViewProgress *) webViewProgress updateProgress :( float) progress {if (progress = 0.0) {[UIApplication sharedApplication]. networkActivityIndicatorVisible = YES; _ progressView. progress = 0; [UIView animateWithDuration: 0.27 animations: ^ {_ progressView. alpha = 1.0 ;}] ;}if (progress = 1.0) {[UIApplication sharedApplication]. networkActivityIndicatorVisible = NO; [UIView animateWithDuration: 0.27 delay: progress-_ progressView. progress options: 0 animations: ^ {_ progressView. alpha = 0.0; // After webView is fully loaded, CGFloat height = [[_ webView stringByEvaluatingJavaScriptFromString: @ "document. body. clientHeight "] floatValue]; CGRect frame = _ webView. frame; frame. size. height = height; _ webView. frame = frame;} completion: nil];} [_ progressView setProgress: progress animated: NO];} @ end