我正在一个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;
}
任何人都可以帮助你吗?没有代码,没有错误信息,什么都没有。你需要包含相关的代码。 – bryanmac 2012-03-23 04:31:34
为您的didSelectRowAtIndexPath实施添加代码,以及它与之交互的任何属性,对象,函数 – bryanmac 2012-03-23 04:33:21
对不起,我已经提供了代码 – MACMAN 2012-03-23 04:45:41