【发布时间】:2011-08-19 14:17:34
【问题描述】:
我只是将我的 tableview 更改为读取富文本而不是纯文本,所以我的解决方案是将富文本加载到 UIWebview 中,然后将 webview 添加到 tableview 单元格内容视图中。 但是,通过此更改,文本将不再显示。这是 -cellForRowAtIndexPath 的代码:
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellTVIdentifier = @"CellTVIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellTVIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellTVIdentifier]
autorelease];
}
int row = indexPath.row;
NSString *cellString = [theArray objectAtIndex:row];
// replaced cell.textLabel.text=cellString;
// with
UIWebView *webTVCell = [[UIWebView alloc] init];
[webTVCell loadHTMLString:cellString baseURL:nil];
[cell.contentView addSubview:webTVCell];
[webTVCell release];
return cell;
但是,cellString 中的文本不再出现在 tableview 的任何单元格中。有人可以帮忙吗?将不胜感激。
【问题讨论】:
标签: uitableview uiwebview