I\'m building a table with some text that is HTML, so I am using a UIWebView as a subview of my custom table cells. I already ran into one problem - as I scrolled down in th
So here's my updated answer: I've implemented a table using one big UIWebView to put styled text inside table cells in my own Twitter client app, HelTweetica (with source available). It works pretty well as long as you understand how to do layout in HTML and CSS.
You just create a NSMutableString and add the lines of HTML that make up your document. You can references external files such as CSS files that are in your app's sandbox. You can set custom URL actions such as "youraction://file.txt" that your web view delegate can intercept and process as a replacement IBActions:
- (void) refreshWebView {
TwitterAccount *account = [twitter currentAccount];
NSMutableString *html = [[NSMutableString alloc] init];
// Open html and head tags
[html appendString:@"\n"];
[html appendString:@"\n"];
[html appendString:@"\n"];
[html appendString:@""];
[html appendString:@""];
[html appendString:@""];
// Body
[html appendString:@""];
// [...]
// Close artboard div, body. and html tags
[html appendString:@"\n"];
NSURL *baseURL = [NSURL fileURLWithPath: [[NSBundle mainBundle] bundlePath]];
[self.webView loadHTMLString:html baseURL:baseURL];
[html release];
}
And you can reload parts of the page by using javascript:
- (void) refreshTabArea {
NSString *html = [self stringByEscapingQuotes: [self tabAreaHTML]];
NSString *js = [NSString stringWithFormat: @"document.getElementById(\"tab_area\").innerHTML = \"%@\";", html];
[self.webView stringByEvaluatingJavaScriptFromString:js];
}