iOS WKWebView improperly calculating height when there is embedded tweet

ios

#1

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=“https://twitter.com/hashtag/SYRIA?src=hash”>#SYRIA Admiral Essen frigate launched <a href=“https://twitter.com/hashtag/Kalibr?src=hash”>#Kalibr cruise missiles against ISIS objects near Deir ez-Zor <a href=“https://t.co/azHAIii07g”>pic.twitter.com/azHAIii07g

— Минобороны России (@mod_russia) <a href=“https://twitter.com/mod_russia/status/905007557554700288”>September 5, 2017

<script src=“https://platform.twitter.com/widgets.js”>”

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

Any advice is appreciated??


#2

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


#3

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: https://dev.twitter.com/web/javascript/events