2012-03-23 94 views
-2

我正在一个iPhone应用程序中列出一些表格视图中的项目。我遇到错误事件TreasureList tableView:didSelectRowAtIndexPath,同时点击一个项目。我对这个错误感到困惑。该错误是TreasureList中的僵尸错误tableView:didSelectRowAtIndexPath

[TreasureList tableView:didSelectRowAtIndexPath:]: message sent to deallocated instance 0x7ce0020

代码是为下:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 

ProductModel *data=[[ProductModel alloc]init]; 
    data=[self.treasureData objectAtIndex:indexPath.row]; 

pid= [NSString stringWithFormat: data.ID];//WithFormat:@"%@",data.ID]; 

也请让我知道我可以调试信息“释放的实例0x7ce0020”

我将数据添加到tableivew采取以下方式。

- (UITableViewCell *)tableView:(UITableView *)tableView 
    cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier"; 
UITableViewCell *cell = [tableView 
         dequeueReusableCellWithIdentifier:SimpleTableIdentifier]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault 
            reuseIdentifier:SimpleTableIdentifier] autorelease]; 
} 
ProductModel *data=[self.treasureData objectAtIndex:indexPath.row]; 
cell.textLabel.text = [NSString stringWithFormat:data.pName]; 
    [data 
    release]; 
return cell; 
} 
+0

任何人都可以帮助你吗?没有代码,没有错误信息,什么都没有。你需要包含相关的代码。 – bryanmac 2012-03-23 04:31:34

+0

为您的didSelectRowAtIndexPath实施添加代码,以及它与之交互的任何属性,对象,函数 – bryanmac 2012-03-23 04:33:21

+0

对不起,我已经提供了代码 – MACMAN 2012-03-23 04:45:41

回答

1

@Gijo你可能会得到这个错误,由于一些消息已经被发​​送,你要么用你的表格单元格,或当你试图在

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
使用的东西已经释放的对象

方法,它已经被释放,即一些对象,标签等。

+0

这是否与自定义单元格有关? – MACMAN 2012-03-23 04:58:17

+0

是的几乎可能,请放一些代码并相应地更新您的问题。在询问任何与崩溃或其他相关的任何事情时,总是会感激代码:-) – 2012-03-23 05:01:21

+0

我用我用来填充Tableview的代码修改了我的原始问题。 – MACMAN 2012-03-23 05:15:53