いくつかのテーブルビューセルを含むテーブルビューがあります。テーブルビューセルは、タイトル(UILabelを使用)、画像(UIWebViewを使用)、および要約(UITextViewを使用)で構成されます。
画像にUIImageを使用すると、すべてが正常に実行されます。しかし、その後、UIImageの代わりにサイズ変更されたUIWebViewを使用して写真を表示することにしました。UITextViewの要約の一部が予期せず変更されます。
テーブルをスクロールすると、問題が解決することがあります。ただし、別のテーブルビューセルにランダムに再び表示される可能性があります。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
TableViewCell *cell = (TableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"TableViewCell" owner:self options:nil];
cell = table;
self.table = nil;
}
//Configure the cell...
Article *article = [_articleRepository fetchArticleById:[articleIds objectAtIndex:indexPath.row]];
cell.headline.text = article.articleTitle;
// Remove html tag
NSString *substringContent = [self stringByStrippingHTML:article.articleContent];
cell.content.text = substringContent;
cell.selectionStyle = UITableViewCellSelectionStyleGray;
ImageRepository *imageRepository = [[ImageRepository alloc]init];
Image *image = [imageRepository fetchImageById:article.articleImage];
NSMutableString *mutUrl = [[NSMutableString alloc]initWithString:image.imageUrl];
[mutUrl insertString:@"_thumb" atIndex:[mutUrl length]-4];
NSString *stringUrl = [[NSString alloc]initWithString:mutUrl];
NSString *htmlImage = [NSString stringWithFormat:@"<html><head><style type=\"text/css\">body{margin: 0; padding: 0;}</style></head><body><img src=\"%@\"></body></html>", stringUrl];
[cell.image loadHTMLString:htmlImage baseURL:nil];
return cell;
}