2011-06-03 64 views
0

当我尝试使用自定义TableCellView时,我的第一个IOS程序崩溃。在iOS中使用customcellview时发生崩溃

// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath { 
AuthorizeTableCell *cell = (AuthorizeTableCell*) [tableView dequeueReusableCellWithIdentifier:@"AuthorizeCell"]; 

if (cell == nil) { 
    cell = [[[NSBundle mainBundle] loadNibNamed: @"AuthorizeTableCell" owner:self options:nil] objectAtIndex:0 ];     
} 

cell.batchIDLabel.text = [[self.authorizeList objectAtIndex:indexPath.row] valueForKey:@"batchID"]; 
cell.amountIDLabel.text = [NSString stringWithFormat:@"%@", [[self.authorizeList objectAtIndex:indexPath.row] valueForKey:@"amount"]] ; 

return cell; 
} 

AuthorizeTableCell类只在TableCellView中包含2个标签和1个按钮。我确定这个3部分已经在课堂上分配了。如果我使用标准的TableCellView,程序可以正常运行。有人可以给我一些建议吗?

THX 帽

+0

日志终端有哪些错误?你可以发布堆栈跟踪吗?从上面的代码看起来好像 – 2011-06-03 09:42:44

+0

哪一个是你的customcell的父类? UITableViewCell的? – itZme 2011-06-03 09:47:16

+0

我打开NSZombieEnabled = YES 和控制台显示 *** - [CALayer的保留]:发送到释放实例 – Cap 2011-06-03 09:48:30

回答

0

抱歉,我在定制单元运行了错误的命令的dealloc

-void dealloc { 
[component1 dealloc]; 
[component2 dealloc]; 
[component3 dealloc]; 
[super dealloc]; 
} 

后,我把它变成 '释放',它工作得很好^ _^ THX