我正在设定我的身高:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat rowHeight = 0;
if(indexPath.row == [self.items count]){ //more
rowHeight = 50.0; //same as moreCell
}
else{
ChartlyCell *cell = (ChartlyCell*)[self tableView:tblView cellForRowAtIndexPath:indexPath];
rowHeight = cell.totalHeight;
}
return rowHeight;
}下面是计算cell.totalHeight的方法:
-(float)totalHeight {
float h = messageLabel.totalheight + 35;
if(h < 68) h = 68;
return h;
}当NSZombieEnabled = NO时,我的模拟器崩溃时没有调试错误。当NSZombieEnabled = YES运行时模拟器运行良好。不知道怎么解决?
更新:--这是我如何构建初始化单元格的方法:
cell = [[[ChartlyCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier andDelegate:self andChartlyDelegate:self andChartlyObj:myChartlyObject]autorelease];如果我删除自动释放,一切正常。我还是很困惑为什么?
发布于 2010-07-22 16:10:04
见可可记忆管理指南。
假设cell是一个实例变量,请考虑:
cell = [[[ChartlyCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier
andDelegate:self
andChartlyDelegate:self
andChartlyObj:myChartlyObject]autorelease];这将导致在池耗尽时收获cell,从而使cell指向现在已释放的ChartlyCell实例。如果你想要一个物体停留在周围,它必须被保留。保留指的是alloc,而实际上是autorelease撤消的。移除autorelease使对象保持在周围。
仿真器应该在启用僵尸的情况下返回错误。奇怪的是,它没有。通过http://bugreport.apple.com/文件一个错误,并附上一个建立的副本,您的应用程序崩溃的版本与这个问题的链接。
https://stackoverflow.com/questions/3310460
复制相似问题