我有一個高單元格的表格視圖。身高約300。單元格是自定義的,並有一個關聯的筆尖。在cellForRowAtIndexPath中,我使用indexPath.row訪問數組中的對象。該對象具有屬性,我將其分配給自定義單元格上的標籤。這適用於前兩個單元格。一旦我滾動足夠的第三個單元格創建,該應用程序崩潰。如何解決uitableview中對象的釋放問題?
我已經NSZombieEnabled集,這裏是輸出:
2010-04-19 21:48:13.360 MyApp[54463:207] *** -[CALayer release]: message sent to deallocated instance 0xfc4e50
(gdb) continue
2010-04-19 21:48:18.382 MyApp[54463:207] *** NSInvocation: warning: object 0xfc4e50 of class '_NSZombie_CALayer' does not implement methodSignatureForSelector: -- trouble ahead
2010-04-19 21:48:18.383 MyApp[54463:207] *** NSInvocation: warning: object 0xfc4e50 of class '_NSZombie_CALayer' does not implement doesNotRecognizeSelector: -- abort
(gdb) continue
Program received signal: 「EXC_BAD_ACCESS」.
(gdb)
我不知道什麼被釋放。我怎樣才能追溯到源?
- 編輯 -
添加的cellForRowAtIndexPath執行:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
OrderCell *cell = (OrderCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"OrderCellView" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
// Set up the cell...
if(self.rows != nil){
id obj = [self.rows objectAtIndex:indexPath.row];
cell.orderId.text = [NSString stringWithFormat:@"%@",[obj objectForKey:@"OrderId"]];
cell.orderName.text = [NSString stringWithFormat:@"%@",[obj objectForKey:@"OrderName"]];
}
return cell;
}
聞起來像是一個由出隊單元重新使用引發的問題 - 但對我而言,如果沒有看到更多的代碼,就無法提供幫助。 – Till 2010-04-20 05:11:22
我已經添加了cellForRowAtIndexPath實現。這還有幫助嗎?謝謝。 – 4thSpace 2010-04-20 05:53:32