Uitableview の各 tableviewcell に各 webview を表示する必要があります。以下のコードを使用すると、2 つの要素がある場合、最初のセルは空ですが、2 番目のセルは正しいです。
hrs および hrsHtml にはすべての値が含まれています。問題は、テーブルビューの適切なセルに最後のデータのみが表示されていることです。他のセルは空白です。
また、セルの合計は 2 です。最初は 2 番目のセルしか表示できませんでしたが、スクロールするとテーブルビューがリロードされ、2 番目のセルが消えて 1 番目のセルが表示されます。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [brId count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];
if (cell == nil) {
cell = [[ UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell.contentView addSubview:hrs];
hrsHtml = [NSString stringWithFormat:@" <font size=\"2\" face=\"Arial\">%@ </font>",[html objectAtIndex:indexPath.row]];
[hrs loadHTMLString:hrsHtml baseURL:nil];
return cell;
}
tableview が表示されたときのスクリーンショット、セル 2 の webview のみ
テーブルビューがスクロールするときのスクリーンショット、セル 1 の Web ビューのみ、セル 2 が消える