[英]iOS 9 UIWebView get html document width and height
在iOS8中,我將webView的原始大小設置為(1,1)。 我使用webView.scrollView.contentSize來獲取html的寬度和高度(html meta width = device-width),然后適合webView的大小。 它運作良好。 但是在iOS9中,我使用xcode 7重建了應用程序。我發現webView contentSize錯誤(寬度小於設備寬度)。 那是iOS9中的UIWebView錯誤嗎?
這是代碼:
(UIWebView *)snapshotWebView {如果(!_snapshotWebView){_snapshotWebView = [[MTXWebView alloc] initWithManager:self frame:ORIGIN_FRAME]; _snapshotWebView.webViewDelegate =自我; } return _snapshotWebView; }
(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]; self.completionBlock(圖像); self.snapshotWebView.frame = ORIGIN_FRAME; }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.