i am not sure if this is a good route to go,...i have some data i receive from the web which in turn, populates a table view. The problem is, the text is html (p tags, etc). My first thought was to create a uiwebview in the cell, and populate with loadHTMLString. Fact is , it KINDA works. But, i then the cell no longer was the recipient of touches.
SO, before we get too deep in code, is there a better way to populate the cells, than using a UIWebView. It feels like a hack, and i fear even if it works, apple would turn it away.
//from my custom UITableViewCell class:
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
[self setFrame:frame];
webcell = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,frame.size.width-20,frame.size.height)];
[self.contentView addSubview:webcell];
//bloack the webview from touches
UIView *cover = [[UIView alloc] initWithFrame:webcell.frame];
[self.contentView addSubview:cover];
[cover release];
}
return self;
}
-(void)setLabelData:(FeedItem *)feedItem
{
link = feedItem.link;
NSMutableString *htmlstring = [NSMutableString string];
[htmlstring appendString:@"<html><head><link rel='stylesheet' href='style.css'/></head><body>"];
[htmlstring appendFormat:@"<p>%@</p>",feedItem.title];
[htmlstring appendFormat:@"<p>%@</p>",feedItem.description];
[htmlstring appendString:@"</body></html>"];
[webcell loadHTMLString:htmlstring baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]bundlePath]]];
}
thanks