2012-05-03 47 views
0

我已经看到与其他许多人的这个问题,通过所有的主题,但我似乎无法找到一个解决方案。当滚动列表时,应用程序崩溃

所以我有一个普通的表格视图,一个单元格链接到一个.xib文件,首先启动一切看起来很正常,但一旦我开始滚动应用程序崩溃立即。

通过让僵尸对象我得到这个错误:

2012-05-03 16:18:13.008 coop_dev[27547:f803] * -[ActivityTableViewController tableView:cellForRowAtIndexPath:]: message sent to deallocated instance 0x6853990

但我不知道要寻找什么,或者什么可能出错:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 
    ItemCell *cell = (ItemCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if(cell == nil) 
    { 
     NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ItemCell" owner:nil options:nil]; 
     cell = [topLevelObjects objectAtIndex:0]; 
    } 

    Item *item = [self.activity objectAtIndex:indexPath.row]; 

    [[cell projectLabel] setText:item.project]; 
    [[cell descriptionLabel] setText:item.description]; 
    [[cell timeLabel] setText:item.time]; 
    [[cell timeAgoLabel] setText:item.timeAgo]; 
    //cell.avatar = [UIImageView item.avatar]; 

    cell.descriptionLabel.numberOfLines = 0; 
    [cell.descriptionLabel sizeToFit]; 

    // remove the right arrow 
    cell.accessoryType = UITableViewCellAccessoryNone; 

    return cell; 
} 

它工作正常,在第一次发射但只是崩溃

编辑

后,我重新创建一个新的问题项目,只是一个包含一些数据的基本表格,一旦你开始滚动它崩溃。下载:http://dl.dropbox.com/u/274185/TestTable.zip

+0

尝试确保self.activity不为零 – danielbeard

+0

我设置了一些断点,但在它到达之前似乎崩溃了 –

+0

我不认为您发布的代码与您的问题有关。请发布实例化ActivityTableViewController的代码。 –

回答

2

在您的FirstViewController.xib中,删除UITableViewController,但保留UITableView。发生崩溃的原因是File's Owner已被设置为Identity Inspector中的FirstViewController类,就好像您有第二个UITableViewController。请确保UITableView已连接到控制器的视图插座。

+0

这对那个应用程序是有意义的,然后在我正在工作现在的结构有点不同:http://dl.dropbox.com/u/274185/coop_dev.zip –

+0

问题是在你的ActivityViewController.xib相同 - 删除UITableViewController那里,但离开UITableView – graver

+0

但是,将如何我以这种方式控制桌子?它现在由ActivityViewTableController控制 –

0

你出列码是有点过...尝试矿:

 UITableViewCell *cell = [[UITableViewCell alloc] init]; 
cell = nil; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
            reuseIdentifier:@"cell"] 
      autorelease]; 


    cell.imageView.image = nil; 
    cell.textLabel.text = nil; 

} 
+0

OP要从NIB的单元格,而不是创建一个新的。 – ssteinberg

0

检查ItemCelldealloc方法,你可能overreleasing东西。

+0

我只有[super dealloc];在这里,这是我的ItemCell作为参考:http://pastebin.com/2J37Gjx2 –

+0

请看看我的编辑,我附上了一个演示项目 –