我正在一個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