0

In my custom UIViewController I have two distinct UIWebViews for which my custom UIViewController is the delegate. In webViewDidFinishLoad:webView I call [webView sizeToFit] and I can confirm it gets called twice, one for each UIWebView. However, to my great dismay, it only seems to affect the first one that gets called, while the other one remains unchanged. Obviously both their contents exceed the bounds, so I expect them to be resized accordingly.

Now, after lots of hours spent on this issue, how am I even supposed to proceed to understand what's wrong?

EDIT: Alright, apparently the problem is that the view in which I put the second UIWebView is not visible on the screen when I call sizeToFit. Calling it with a delay after the view is shown results in the expected behaviour. Now I have to find a way to do this without showing it, because I need to to be visible at a later time. Ideas?

Morpheu5
  • 2,610
  • 6
  • 39
  • 72
  • To be clear, you're trying to resize web view to appropriate size based on loaded content? – TheBlack Jun 03 '11 at 23:39
  • If it was the other way around, scalesPageToFit can be set before loading content... See if view is resized when UIView hidden property is set to YES. This way the second view can be added to parent view together with first view but with setHidden:YES. Then instead of adding second view as subview just set hidden property to NO. – TheBlack Jun 04 '11 at 09:19

1 Answers1

0

It seems that doing that on viewDidAppear works like a charm.

Morpheu5
  • 2,610
  • 6
  • 39
  • 72