Context
- Single
ViewController
- Two
UIWebView
objects as subviews of aUIScrollView
are in thisViewControllers
view - The ViewController is the delegate of both UIWebViews
- The delegate method
- (void)webViewDidFinishLoad:(UIWebView *)webView
gets called twice as expected for bothUIWebViews
- I'm setting the height of these
UIWebViews
usingsizeThatFits
once their content has loaded (in thewebViewDidFinishLoad
method
What I want to do
Once both WebViews have loaded their content I want to set the height of the UIScrollView
that they are in relative to the WebViews height. Basically I want the UIScrollView
to be tall enough to scroll all the way through the text in the UIWebViews
.
Possible Solutions I've thought of
- Have a counter within the
webViewDidFinishLoad
method, and when it is equal to the amount of WebViews on the view call a method that sets the height of theUIScrollView
. - Call set height of
UIScrollView
inwebViewDidFinishLoad
- it will be called multiple times, but the last call will be the correct height.
Question
How do I work out when both webViews have loaded in a "better" way than the possible solutions above?