title: Rendering a UIWebView in drawRect with loadHTMLString
body: <p>I am having a problem with UIWebView. I'd like to render my own html code in it. When I add a webview as a subview and put in some html code it renders just fine. When it gets down to some optimized drawing of tableview cell with the drawRect method the problem pops up. Drawing UIView descendants works pretty well this way. It's even possible to load a URL with the loadRequest method, setting the delegate, conforming to the UIWebViewDelegate protocol and redrawing the table cell with setNeedsDisplay when webViewDidFinishLoad is called. It does show, but when it comes to loadHTMLString, nothing shows up, only a white rect. Due to performance reasons I have to do the drawing in the drawRect method. </p>
  
  <p>Any ideas? Thanks in advance
  Nick</p>
  
  <p>Example snippet code for the html code being loaded by a UIWebView:</p>
  
  <pre><code>NSString *html = @"&lt;html&gt;&lt;head&gt;&lt;title&gt;My fancy webview&lt;/title&gt;&lt;/head&gt;&lt;body style='background-color:green;'&gt;&lt;p&gt;It somehow seems&lt;h2 style='color:black;'&gt;this does not show up in drawRect&lt;/h2&gt;!&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;"; 
  [webView loadHTMLString:html baseURL:nil];
  </code></pre>
  
  <p>Snippet for the drawRect method:</p>
  
  <pre><code>- (void)drawRect:(CGRect)aRect {
      CGContextRef context = UIGraphicsGetCurrentContext();
  
      [[webView layer] renderInContext:context];
  }
  </code></pre>