简体   繁体   中英

iOS 9 UIWebView get html document width and height

in iOS8, I set webView origin size is (1,1). I use webView.scrollView.contentSize to get the html width and height(html meta width=device-width), then fit the webView size. it works well. But in iOS9, I rebuild the app with xcode 7. And I get the webView contentSize is wrong(width is less than device width). so is it a UIWebView bug in iOS9?

Here is the code:

define ORIGIN_FRAME CGRectMake(0, 0, SCREEN_WIDTH, 1)

  • (UIWebView *)snapshotWebView { if (!_snapshotWebView) { _snapshotWebView = [[MTXWebView alloc] initWithManager:self frame:ORIGIN_FRAME]; _snapshotWebView.webViewDelegate = self; } return _snapshotWebView; }

  • (void)webview:(MTXWebView *)webView doLoad:(NSDictionary *)data callback:(WVJBResponseCallback)responseCallback { webView.frame = CGRectMake(0, 0, webView.scrollView.contentSize.width, webView.scrollView.contentSize.height); UIImage *image = [_snapshotWebView renderToImage]; self.completionBlock(image); self.snapshotWebView.frame = ORIGIN_FRAME; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM