iOS WKWebView improperly calculating height when there is embedded tweet



My app uses WKWebView to present html string. WkWebView is embedded in a scrollView because i have several other elements (e.g. buttons, tableViews). Because of that i need to calculate the size of WkWebvView content and for that i use evaluateJavaScript(“document.body.scrollHeight”, completionHandler: method.
Whenever i have embedded tweet in a html string, content height is wrongly calculated and my webview cuts a piece of its height.
Part of html string which has tweet embedded looks like this:

“<blockquote class=“twitter-tweet” data-lang=“en”>

<a href=“”>#SYRIA Admiral Essen frigate launched <a href=“”>#Kalibr cruise missiles against ISIS objects near Deir ez-Zor <a href=“”>

— Минобороны России (@mod_russia) <a href=“”>September 5, 2017

<script src=“”>”

Is there something missing in this code, or should i set something in webview methods?

Any advice is appreciated??


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.


Hi! Your issue is likely caused because the initial blockquote code gets replaced by our script with the fully functional widget. This happens after the initial page load, so you may be measuring the view too soon. You need to listen for page size changes in the content to ensure you WebView updates in a corresponding manner.

There are also some dedicate rendered events from embedded you can listen for in the page. See: