title: How can I detect the completion of view layout for a UIWebView
body: <p>I want to allow a user to associate a zoom factor with a document and use it as a starting point when displaying that document inside a UIWebView.  It seems, however, that <code>webViewDidFinishLoad:</code> only indicates the end of in-memory loading, not including rendering or layout.  Here's sample code to demonstrate the problem:</p>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];
      UIWebView *webView = (UIWebView *)self.view;
      webView.delegate = self;
      webView.scalesPageToFit = YES;
  }
  
  - (void)viewDidAppear:(BOOL)animated {
      [super viewDidAppear:animated];
  
      NSString *urlString = [[NSBundle mainBundle] pathForResource:@"Doc" ofType:@"pdf"];
      NSURL *file = [NSURL fileURLWithPath:urlString];
      [(UIWebView *)self.view loadRequest:[NSURLRequest requestWithURL:file]];
  }
  
  - (void)webViewDidFinishLoad:(UIWebView *)webView {
      if (!webView.isLoading) {
          [webView.scrollView setZoomScale:1.5 animated:YES];
      }
  }
  </code></pre>
  
  <p>The call to setZoomScale: executes with no effect (i.e. the file is displayed with a zoom factor of 1.0), apparently because it happens before the scroll view is in some state where it can deal with it.  If I change the final method above to what follows, everything works as I'd hoped.</p>
  
  <pre><code>- (void)delayedZoomMethod {
      [((UIWebView *)self.view).scrollView setZoomScale:1.5 animated:YES];
  }
  
  - (void)webViewDidFinishLoad:(UIWebView *)webView {
      [self performSelector:@selector(delayedZoomMethod) withObject:nil afterDelay:1.0];
  }
  </code></pre>
  
  <p>This, of course, is a bad idea because the 1.0 delay is arbitrary, probably too long for the vast majority of cases, and will likely be too short under some unknown set of conditions.</p>
  
  <p>The docs say, "<em>Your application can access the scroll view if it wants to customize the scrolling behavior of the web view.</em>"  Does anyone know of a notification, or property in the web view or its scroll view, that I could observe to be told <strong>when</strong> that statement becomes true?</p>