单击按钮时,在ios中继续收到错误的访问错误

时间:2014-01-11 23:56:27

标签: ios cocoa-touch

所以,当我点击视图中的按钮时,我收到了一个BAD ACCESS错误。我认为这是发生的,因为我正在创建视图控制器,然后将视图返回到一个函数,该函数将所述视图作为子视图添加到表格单元格。

喜欢这个 -

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

if([self.resultsTuples count] != 0){
    NSDictionary* rowData = self.resultsTuples[indexPath.row];
    UITableViewCell* tableCell = [self.resultTable dequeueReusableCellWithIdentifier:CellTableIdentifier];
    UIView* cardView = [cardChooser getCardView:rowData];
    [tableCell addSubview:cardView];
    return tableCell;
} else {
    return nil;

}
return nil;

}

一切都正确呈现 - 我只有一个按钮,当我点击它时,我得到了EXC_BAD_ACCESS。似乎在xib文件中正确连接了所有内容。

我知道这个问题不太可能得到直接的答案,但任何关于在哪里寻找错误的想法都会有所帮助。

我也知道连接到按钮的功能不是问题,因为

  - (IBAction)map:(id)sender{
    NSLog(@"LAT AND LON : %@, %@", self.latitude,self.longitude);
    [MapUtils displayLocationOnMap:self.latitude withLongitude:self.longitude];
    [MapUtils displayDirectionFromCurrentLocationOnMap:self.latitude withLongitude:self.longitude];
}

在错误访问之前不运行NSLog。

这是确切的错误 -

Thread 1:EXC_BAD_ACCESS(code=1, address=somePointer)

这可能是内存问题吗?

这就是我返回视图的方式 -

-(UIView*)getCardView:(NSDictionary*) component{
    return [self getGeneralResultView: component];

}

-(UIView*)getGeneralResultView:(NSDictionary*)component{
    GeneralResultViewController* generalResultVC = [[GeneralResultViewController alloc]initWithNibName:@"GeneralSearchResult" bundle:nil];
    generalResultVC.name = someName;
//do other stuff
    return generalResultVC.view;
}

我猜想有些事情 - 视图控制器已经消失了,并且没有按钮。

0 个答案:

没有答案
相关问题