2014-10-11 40 views
0

(Xcode 5,ios7,arc)我有一個視圖控制器,它有一個tableview,問題是單元格加載圖片,造成內存泄漏。我反覆推視圖控制器,然後回來,內存不斷增加。我的英文不好,不知道是否清楚表達。
如何解決圖片內存過多的問題,希望能夠掌握幫助。
下面是代碼:單元內存警告圖像

@implementation SearchCell 
-(void)dealloc 
{ 
    _imageV = nil; 
    _titleL = nil; 
    _infoL = nil; 
    _countL = nil; 
} 
+(instancetype) cellWithTableView:(UITableView *)tableView model:(SearchModel *)model 
{ 
    static NSString* strID = @"SPECIALCELL"; 
    SearchCell* cell = [tableView dequeueReusableCellWithIdentifier:strID]; 
    if (cell == nil) { 
     cell = [[[NSBundle mainBundle] loadNibNamed:@"SearchCell" owner:nil options:nil] lastObject]; 
    } 
    [cell setSearchCellModel:model]; 
    return cell; 
} 
-(void) setSearchCellModel:(SearchModel*)model 
{ 
    UIImage* img = [[SDWebImageManager sharedManager] imageWithURL:[NSURL URLWithString:model.tvImgURL]]; 
    self.imageV.image = img; 
    self.titleL.text = model.tvName; 
    self.infoL.text = model.tvInfo; 
    self.countL.text = model.tvCount; 
} 
+0

它可能會讓你的圖像有一個非常大的分辨率。如果將圖像調整爲圖像視圖的大小並設置圖像,則可能更有意義。 – Sandeep 2014-10-11 10:39:21

+0

謝謝,在網絡上後圖片確實很大,調整大小,內存也沒有增加 – 2014-10-11 12:03:54

回答

0

hear 你得到你的答案這個問題......你需要使用鐳石光電加載圖像視圖..

我想給暗示了點。

1)。首先你需要保存圖像文件目錄唯一的名稱(url名稱),然後檢查圖像是否存在於文檔目錄,然後你從文檔目錄文件夾中獲取圖像,當你保存圖像時,你保存圖像小尺寸使用此link code輕鬆解決你的問題。

+0

謝謝,雖然知道延遲加載,但用處不大。我剛開始學習,請原諒 – 2014-10-11 12:10:12

+0

只看編輯我的答案。我希望你能得到你的解決方案。 – 2014-10-11 12:34:26