2015-08-09 30 views
0

這裏是我的代碼:從故事板中加載自定義的UITableViewCell沒有得到dealloc'ed

__weak CurrentViewController *weakSelf = self; 
if (indexPath.row == 0) //Name Cell 
{ 
    static NSString *CellIdentifier = @"NameCell"; 
    NameCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    __weak NameCell *weakCell = cell; 
    cell.NameDidChangeBlock = ^(){ 
     weakSelf.zoneName = weakCell.NameTextField.text; 
    }; 

    return cell; 
} 
else if (indexPath.row == 1) //Number Cell 
{ 
    static NSString *CellIdentifier = @"NumberCell";   
    NumberCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    cell.someBlock = ^(){ 
     [weakSelf.navigationController popViewControllerAnimated:YES]; 
    }; 

    return cell; 
} 

既不是 「NameCell」,也不是 「NumberCell」 dealloc方法獲取調用。 我有這兩個自定義單元格設計和放置在CurrentViewController的故事板中的頂級對象。

CurrentViewController的dealloc被調用,但自定義單元的dealloc不是。 我在儀器中看到,每次創建CurrentViewController實例時,定製單元格的retainCount都會增加。

這裏是我的自定義細胞的標題:

//NameCell.h: 
@property(nonatomic, weak)IBOutlet UITextField *NameTextField; 
@property (nonatomic, copy)NameDidChange NameDidChangeBlock; 

//NumberCell.h 
@property(nonatomic, weak)Manager *manager; 
@property(nonatomic, weak)IBOutlet AKPickerView *pickerView; 
@property(nonatomic, strong)NSArray *numbersArray; 
@property(nonatomic)int selectedZoneNumber; 
@property (weak, nonatomic) IBOutlet UIView *selectionBoxView; 
@property (nonatomic, copy)some someBlock; 

這裏任何幫助,將不勝感激。 謝謝!

編輯: 我的tableView本身沒有得到dealloc'ed後currentViewController獲得dealloc'ed。 嘗試登錄UITableView類別。 不過,猜測,當我的viewController已經發布時,爲什麼我的tableView不會被釋放。似乎太奇怪了。

+1

當你檢查單元是否被釋放?單元由tableView擁有,它可以重用單元,所以它不會釋放它們。 tableView由控制器的視圖(父)擁有,並且當視圖控制器被取消分配時,所有對象都將被釋放。 –

+0

回答@LucianBoboc:即使在CurrentViewController被取消分配之後,我看到單元沒有被釋放(在Instruments [Allocations工具]中)。 另外,自定義單元格中的「dealloc」方法沒有被調用。 這些方法適用於「cellForRowAtIndexPath」方法。 – CoderSaru

+0

你使用ARC嗎? – hasan83

回答

0

的罪魁禍首是這個傢伙:ShowKit

我們有ShowKit融入我們的應用程序進行遠程支持。

從我們的應用程序中刪除他們的SDK確實解決了上面提到的dealloc問題(不僅僅是上面的問題,而是比我們想象的更多的問題)。

我認爲ShowKit SDK確實需要我們的應用程序視圖的副本,並且不會將其返回並且可能是複製視圖的保留計數根本不會變爲0。

OR

可能是SDK有超過我的應用程序的一個UIWindow的手柄和他們不釋放它不需要時。

這純粹是我的猜測,但不知道。他們必須回答。

我希望有人認爲這有幫助。

相關問題