I want to have a UIWebView
inside a UIScrollView
. The UIWebView will sometimes go out of bounds of the iPhone screen so I need a way to scroll the view so I can see all the content (but I don't want to use the built in scrolling of the UIWebView). So I'm thinking of putting all the content inside of a UIScrollView and then making the height of the UIScrollView to equal the height of the UIWebView and other views that are in it.
Here's an image to help describing my problem:
I did exactly the same thing. Here's how I made it work:
The last point is bit tricky because you cannot be sure that the HTML is completely rendered when webViewDidFinishLoad: gets called on the UIWebViewDelegate.
Here's a reliable way to get the HTML content size:
1.Add a javascript function to the HTML that gets called when the HTML Document is ready:
This functions sends a request that has the content height in it's URL.
2.In your UIWebViewDelegate you intercept this request:
Hope that helps
UPDATE
Here is the Swift 2 version: