Timo Cengiz
Timo Cengiz

Reputation: 3417

Get the CORRECT size of an UIWebView after it has loaded, swift

I am having so much trouble showing a simple vimeo videon on my UIWebView. I have come so far that i can show the video and it is able to play in fullscreen mode.

The problem is that the video is not fitting properly inside my UIWebView.

In storyboard the UIWebView is set to have 560 in width and 105 in height. This is obviously changed in runtime since it resizes to fit different screens.

This becomes a problem because in the html embedded code that is needed to show the video is where you specify the videos size such as width and height.

So now for my question.. How can i get the correct size of my UIWebView after it has been loaded and all so i can match it with the videos frames?

Upvotes: 0

Views: 708

Answers (1)

ABM
ABM

Reputation: 77

If your web view fills the whole view you can get the views frame and get the width and height from there.

Call this code in viewDidAppear():

let height = view.frame.height
let width = view.frame.width

Upvotes: 1

Related Questions