2011-06-03 79 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