title: UIWebView does not load or appear when created programmatically
body: <p>I'm debugging a custom <code>UIViewController</code> subclass, which wraps a <code>UIWebView</code> so that we can handle custom URLs.</p>
  
  <p>I seem to have no problem adding the relevant views to the hierarchy, but when I call <code>loadRequest:</code> on the webview, it displays nothing.  It <em>seems</em> as though it is not even attempting to execute the request, either - my subclass is setting itself as the <code>UIWebView</code>'s delegate, but is not receiving any delegate callbacks from it, not even <code>webViewDidStartLoad</code> or <code>shouldStartLoadWithRequest</code> (!).  What could be causing this?</p>
  
  <p>The following is the relevant code from my class:</p>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];
  
      // add the webview
      m_webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 300, 400)];
      m_webView.delegate = self;
      m_webView.dataDetectorTypes = UIDataDetectorTypeNone;
  
      // adding a border to see if the view is visible onscreen
      [[m_webView layer] setBorderColor:[[UIColor darkGrayColor] CGColor]];
      [[m_webView layer] setBorderWidth:50];
  
      [self.view addSubview:m_webView];
  }
  
  - (void)viewWillAppear:(BOOL)animated {
      [super viewWillAppear:YES];
  
      NSURLRequest *request = [NSURLRequest requestFromUrl:[NSURL urlFromString:@"http://www.google.com"]];
      [self.m_webView loadRequest:request];
      NSLog(@"Loading URL: %@ in view: %@; delegate set as %@", @"http://www.google.com", m_webView, m_webView.delegate);
      NSLog(@"WebView is %@", self.m_webView.loading ? @"loading" : @"not loading");
  
  }
  
  - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
      NSLog(@"Loading URL of type %@, relative = %@", [[request URL] scheme], [[request URL] relativeString]);
      return YES;
  }
  
  - (void)webViewDidStartLoad:(UIWebView *)webView {
      NSLog(@"Started");
  }
  
  - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
      NSLog(@"Failed, error %@", error);
  }
  
  - (void)webViewDidFinishLoad:(UIWebView *)webView {
      NSLog(@"Finished");
      [self finishedReloading];
  }
  </code></pre>
  
  <p>And the code from the controller for the parent view, which tries to add an instance of this one (currently situated in that controller's viewDidLoad method):</p>
  
  <pre><code>ZUIWebViewController *testWebView = [[[ZUIWebViewController alloc] initWithAddress:@"deal/recentDrops"] autorelease];
  [m_scrollView addSubview:testWebView.view];
  [testWebView viewWillAppear:YES];
  NSLog(@"Added webview");
  </code></pre>
  
  <p>The result when I run this is:</p>
  
  <pre><code>Loading URL: http://www.google.com in view: &lt;UIWebView: 0x1114eb30; frame = (0 0; 320 480); layer = &lt;CALayer: 0x1114eb90&gt;&gt;; delegate set as &lt;ZUIWebViewController: 0x1114d7a0&gt;
  Webview is not loading
  Added webview
  </code></pre>
  
  <p>The view hierarchy after the "Added webview" message is:</p>
  
  <pre><code>(lldb) po [m_scrollView recursiveDescription]
  (id) $1 = 0x0a634b00 &lt;UIView: 0xbba3430; frame = (0 20; 320 460); autoresize = W+H; layer = &lt;CALayer: 0xbba3840&gt;&gt;
     | &lt;UIImageView: 0xbba3490; frame = (0 0; 320 480); userInteractionEnabled = NO; layer = &lt;CALayer: 0xbba3940&gt;&gt;
     | &lt;UIScrollView: 0xbba4390; frame = (0 0; 320 480); clipsToBounds = YES; gestureRecognizers = &lt;NSArray: 0xbba4680&gt;; layer = &lt;CALayer: 0xbba4560&gt;; contentOffset: {0, 0}&gt;
     |    | &lt;UIWebView: 0xbba4840; frame = (0 0; 320 480); layer = &lt;CALayer: 0xbba48a0&gt;&gt;
     |    |    | &lt;_UIWebViewScrollView: 0xbba6b70; frame = (0 0; 320 480); clipsToBounds = YES; autoresize = H; gestureRecognizers = &lt;NSArray: 0xbba6f40&gt;; layer = &lt;CALayer: 0xbba6da0&gt;; contentOffset: {0, 0}&gt;
     |    |    |    | &lt;UIImageView: 0xbba7860; frame = (0 0; 54 54); transform = [-1, 0, -0, -1, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0xbba78c0&gt;&gt;
     |    |    |    | &lt;UIImageView: 0xbba77d0; frame = (0 0; 54 54); transform = [0, 1, -1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0xbba7830&gt;&gt;
     |    |    |    | &lt;UIImageView: 0xbba7740; frame = (0 0; 54 54); transform = [0, -1, 1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0xbba77a0&gt;&gt;
     |    |    |    | &lt;UIImageView: 0xbba76b0; frame = (0 0; 54 54); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0xbba7710&gt;&gt;
     |    |    |    | &lt;UIImageView: 0xbba7620; frame = (-14.5 14.5; 30 1); transform = [0, 1, -1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0xbba7680&gt;&gt;
     |    |    |    | &lt;UIImageView: 0xbba7590; frame = (-14.5 14.5; 30 1); transform = [0, -1, 1, 0, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0xbba75f0&gt;&gt;
     |    |    |    | &lt;UIImageView: 0xbba7500; frame = (0 0; 1 30); transform = [-1, 0, -0, -1, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0xbba7560&gt;&gt;
     |    |    |    | &lt;UIImageView: 0xbba7470; frame = (0 0; 1 30); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0xbba74d0&gt;&gt;
     |    |    |    | &lt;UIImageView: 0xbba73e0; frame = (0 450; 320 30); alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0xbba7440&gt;&gt;
     |    |    |    | &lt;UIImageView: 0xbba7380; frame = (0 0; 320 30); transform = [-1, 0, -0, -1, 0, 0]; alpha = 0; opaque = NO; userInteractionEnabled = NO; layer = &lt;CALayer: 0xbba72e0&gt;&gt;
     |    |    |    | &lt;UIWebBrowserView: 0x13baa200; frame = (0 0; 320 480); gestureRecognizers = &lt;NSArray: 0xbba5d50&gt;; layer = &lt;UIWebLayer: 0xbba4930&gt;&gt;
     |    |    |    |    | &lt;TileHostLayer: 0xbba4a00&gt; (layer)
     |    |    |    |    |    | &lt;TileLayer: 0xbba7ef0&gt; (layer)
  </code></pre>
  
  <p>So it doesn't appear that there's anything in front of the <code>UIWebView</code> I'm trying to display.</p>
  
  <p>What could be causing this, and are there any further steps I should be taking to debug?</p>