簡體   English   中英

iOS 9 UIWebView獲取html文檔的寬度和高度

[英]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錯誤嗎?

這是代碼:

定義ORIGIN_FRAME CGRectMake(0,0,SCREEN_WIDTH,1)

  • (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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM