我有一个高单元格的表格视图。身高约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