2012-12-04 43 views
2

我有一個表視圖與幾個表視圖單元格。表格視圖單元由標題(使用UILabel),圖片(使用UIWebView)和摘要(使用UITextView)組成。UITextView中的字體大小意外改變

當我使用UIImage的圖片,一切運行良好。但之後,我決定使用調整大小的UIWebView而不是UIImage顯示圖片。 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; 

}

+0

如何處理一些代碼和截圖? – vikingosegundo

回答

0

這可能是由於在使烏爾問題的tableview重用細胞隨機出現整個細胞。如果你發佈了你已經完成的代碼,會有幫助。
編輯:嘗試更改下面給出的代碼的ur部分。

if (cell == nil) { 

    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"TableViewCell" owner:self options:nil]; 
    cell = [topLevelObjects objectAtIndex:0]; 
} 

一些問題:1。 爲什麼你在做電池=表& self.table =零?

+0

感謝您的回覆。這裏是代碼 –

+0

它在哪裏?你可以編輯你的問題並在那裏添加代碼。 – akdsouza

+0

我編輯了問題 –