I have a problem with UIWebView. I would like to make my own HTML. When I add webview as a subquery and put in some html code, it looks just fine. When he goes to some optimized drawing of a tableview cell with the drawRect method, a problem arises. Drawing UIView descendants works pretty well. It is even possible to load the URL using the loadRequest method by setting the delegate according to the UIWebViewDelegate protocol and redrawing the table cell with setNeedsDisplay when calling webViewDidFinishLoad. It shows, but when it comes to loadHTMLString, nothing appears, only a white rectangle. Due to performance, I have to make a drawing in the drawRect method.
Any ideas? thanks in advance Nick
Sample html code snippet code loaded using UIWebView:
NSString *html = @"<html><head><title>My fancy webview</title></head><body style='background-color:green;'><p>It somehow seems<h2 style='color:black;'>this does not show up in drawRect</h2>!</p></body></html>";
[webView loadHTMLString:html baseURL:nil];
Snippet for drawRect method:
- (void)drawRect:(CGRect)aRect {
CGContextRef context = UIGraphicsGetCurrentContext();
[[webView layer] renderInContext:context];
}
source
share