title: UIWebView difference between iOS 4 and iOS 5 on reading a pdf file
body: <p>I have found a difference between iOS 4 and iOS 5 that caused an error in my code. When I create a <code>UIWebView</code>, it's also created a subview called <code>UIWebBrowserView</code> with a frame of size 577 x 533. Then, I load a PDF file in the <code>UIWebView</code> and here there's a different between iOS 4 and 5. In iOS 4, when the processing reaches the method "webViewDidFinishLoad:", the <code>UIWebBrowserView</code> still exists with frame 577 x 2947 (the size of the pdf, I suppose), and in iOS 5, the <code>UIWebBrowserView</code> doesn't exist anymore and in it's place there's a <code>UIWebPDFView</code> with frame 577 x 533 (here I was expecting a frame with size 577 x 2947). Finally, I cause an event and the views are as I expected (<code>UIWebBrowserView</code> with frame 577 x 2947 in iOS 4 and <code>UIWebPDFView</code> with frame 577 x 2947.4 in iOS 5).</p>
  
  <p>The problem is that when the pdf file is loaded, when the processing reaches the method "webViewDidFinishLoad:" I'd like to put notes in the PDF file, but in this method <code>UIWebPDFView</code> is not yet with the real size of the pdf. If I just put the notes there they don’t appear. In iOS 4 it was working but in iOS 5 it's not working anymore. Anyone can help on how can I put the notes on the loading of webview?</p>
  
  <p>Here is the code which shows that different behavior of both iOS and bellow the log.</p>
  
  <pre><code>ViewController.h
  #import &lt;UIKit/UIKit.h&gt;
  
  @interface ViewController : UIViewController &lt;UIWebViewDelegate, UIGestureRecognizerDelegate&gt;
  {
      IBOutlet UIView *view;
      IBOutlet UIWebView * webView;
  }
  
  - (void)handleTap:(UITapGestureRecognizer *)recognizer;
  
  @end
  
  ViewController.m
  #import "ViewController.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view, typically from a nib.
  
      [webView setUserInteractionEnabled:YES];
      [view bringSubviewToFront:webView];
  
      //Load view with a pdf file
      NSString *path = [[NSBundle mainBundle] pathForResource:@"pdf_teste" ofType:@"pdf"];
      NSData *pdfData = [NSData dataWithContentsOfFile:path];
      [webView loadData:pdfData MIMEType:@"text/pdf" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@""]];
  
      //Log
      NSLog(@"On viewDidLoad: %@", [[webView viewForZoomingInScrollView:(UIScrollView *)[[webView subviews] objectAtIndex:0]] description]);
  
      //Add a tap gesture recognizer
      UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
      recognizer.delegate = self;
      [webView addGestureRecognizer:recognizer];
  }
  
  - (void)webViewDidFinishLoad:(UIWebView *)view
  {
      //Log
      NSLog(@"On webViewDidFinishLoad: %@", [[webView viewForZoomingInScrollView:(UIScrollView *)[[webView subviews] objectAtIndex:0]] description]);
  
      //I’d like to insert the saved notes here.
  
  }
  
  - (void)handleTap:(UITapGestureRecognizer *)recognizer
  {
      //Log
      NSLog(@"On Tap Event: %@", [[webView viewForZoomingInScrollView:(UIScrollView *)[[webView subviews] objectAtIndex:0]] description]);
  }
  
  @end
  </code></pre>
  
  <hr>
  
  <p>Log:</p>
  
  <p>iOS 5.1</p>
  
  <p>2012-03-30 14:24:28.075 WebViewTest[173:707] On viewDidLoad: ></p>
  
  <p>2012-03-30 14:24:28.823 WebViewTest[173:707] On webViewDidFinishLoad: >
  Mar 30 14:24:29 iPad2-de-ASDS WebViewTest[173] : OPDILG+TT857o00: FT_Select_Charmap failed: error 38.</p>
  
  <h2>2012-03-30 14:24:47.167 WebViewTest[173:707] On Pan Event: ></h2>
  
  <p>iOS 4.3.5</p>
  
  <p>2012-03-30 14:13:46.285 WebViewTest[823:607] On viewDidLoad: ></p>
  
  <p>2012-03-30 14:13:47.049 WebViewTest[823:607] On webViewDidFinishLoad: >
  Mar 30 14:13:47 BNBConsult01 WebViewTest[823] : OPDILG+TT857o00: FT_Select_Charmap failed: error 38.</p>
  
  <p>2012-03-30 14:14:48.199 WebViewTest[823:607] On Pan Event: ></p>