Hey all, does anyone know how to properly force we...
# compose-ios
l
Hey all, does anyone know how to properly force webview in compose multiplatform to wrap content? Basically I have a screen that is a big lazy column and one of the items is the webview. On Android it works fine (since AndroidView wraps content) but on iOS unless I specify an exact height it does not work. And webview measuring itself using javascript is not a solution
a
Hi! Why you think JS is not an option? I'm afraid that's the only option... Less hacky then check height of UIScrollView inside WKWebView 🙂
l
because JS is not reliable and also slow (as I need webview to load first and then resize itself which doesnt feel natural
a
I'm not sure what you mean by "not reliable" - web content loading and layout are asynchronous processes, so it can happen that measuring at a random time can give incorrect results, especially if there are some images. It really depends on your content and the method you're using to measure size - there are many. I would suggest finding a solution that injects a hook into JS and triggers some function on size change, which then notifies the Compose code. Anyway, technically it's a 3-way step, so it's hard to make the compose react to it immediately. P.S. As far as I can remember, WKWebView has always been a bit weird. Sometimes it's necessary to create it with quite a huge size, like x2 of the screen size, to make it render all the content, then check the seize.
l
Ah alright. Basically, what I wanna do is just wrapping content. But this is an issue in general with all iOS interop views.
a
Yep, self-sizing is not supported yet on iOS.
l
I've managed to get it somehow working with Javascript. But it's not perfect