[英]iOS 9 UIWebView get html document width and height
in iOS8, I set webView origin size is (1,1). 在iOS8中,我将webView的原始大小设置为(1,1)。 I use webView.scrollView.contentSize to get the html width and height(html meta width=device-width), then fit the webView size.
我使用webView.scrollView.contentSize来获取html的宽度和高度(html meta width = device-width),然后适合webView的大小。 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).
但是在iOS9中,我使用xcode 7重建了应用程序。我发现webView contentSize错误(宽度小于设备宽度)。 so is it a UIWebView bug in iOS9?
那是iOS9中的UIWebView错误吗?
Here is the code: 这是代码:
(UIWebView *)snapshotWebView { if (!_snapshotWebView) { _snapshotWebView = [[MTXWebView alloc] initWithManager:self frame:ORIGIN_FRAME]; (UIWebView *)snapshotWebView {如果(!_snapshotWebView){_snapshotWebView = [[MTXWebView alloc] initWithManager:self frame:ORIGIN_FRAME]; _snapshotWebView.webViewDelegate = self;
_snapshotWebView.webViewDelegate =自我; } return _snapshotWebView;
} 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); (void)webview:(MTXWebView *)webView doLoad:(NSDictionary *)数据回调:(WVJBResponseCallback)responseCallback {webView.frame = CGRectMake(0,0,webView.scrollView.contentSize.width,webView.scrollView.contentSize.height) ; UIImage *image = [_snapshotWebView renderToImage];
UIImage * image = [_snapshotWebView renderToImage]; self.completionBlock(image);
self.completionBlock(图像); self.snapshotWebView.frame = ORIGIN_FRAME;
self.snapshotWebView.frame = ORIGIN_FRAME; }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.