0
我使用ARC,但似乎我的自定義UITableCellView沒有發佈。UITableCell子類永不釋放?
TBMListingLineView是TBMGlobalCustomCell的子類,它是UITableCellView的子類。
在TBMListingLineView有10個UILabels(非原子,保留)
我已經在這兩個類中實現它永遠不會被調用(斷點不停止執行)
當我的方法的dealloc滾動TableView,UILabel的數量在Instruments/Allocations中增加,導致應用程序在幾次內存警告後崩潰。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *CellIdentifier = @"Cell";
TBMGlobalCustomCell* cell;
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
switch(sortIndex) {
case 0 :
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil || ![cell isKindOfClass:[TBMListingLineView class]]) {
cell = [[TBMListingLineView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
break;
....
return cell;
}
爲什麼你調用'dequeueReusableCellWithIdentifier'兩次?如果你的自定義單元是TBMGlobalCustomCell對象,爲什麼要檢查'[TBMListingLineView類]? –
爲什麼要兩次調用dequeueReusableCellWithIdentifier? - > omg ...就是這樣!謝謝 !爲了回答第二個問題,我有5個TBMGlobalCustomCell的不同子類,並且根據sortIndex值,TableCellView不同,再次感謝 – Max
但是調用dequeueReusableCellWithIdentifier,然後用新分配的元素替換出隊單元也沒有意義。更好地爲每個子類使用不同的單元格標識符。 –