首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >"EXC_BAD_ACCESS“在tableView和mapView之间切换过快时

"EXC_BAD_ACCESS“在tableView和mapView之间切换过快时
EN

Stack Overflow用户
提问于 2012-06-05 08:15:21
回答 4查看 1.4K关注 0票数 0

我有一个带有按钮的tableView,可以按mapView。推背动作一般都很好。如果我在这两个视图之间快速切换,就会出现"EXC_BAD_ACCESS“错误。

MapViewController.m

代码语言:javascript
运行
复制
- (void)viewDidLoad
{
[super viewDidLoad];
self.mapView.delegate = self;    

UIButton *btnL = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40.0, 40.0)];
[btnL setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];
[btnL addTarget:self.navigationController  action:@selector(popViewControllerAnimated:) forControlEvents:UIControlEventTouchDown];
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:btnL] autorelease];
[btnL release];

self.whereAmIAnnotation = [[[WhereAmIAnnotation alloc] init] autorelease];

if (!self.mapView || !self.whereAmIAnnotation) {
    NSLog(@"mapview : %@", self.mapView);
    NSLog(@"whereAmIAnnotation : %@",self.whereAmIAnnotation);
 // will never enter in to here
}

[self.mapView addAnnotation:self.whereAmIAnnotation];

}

如果我评论[self.mapView addAnnotation:self.whereAmIAnnotation];,就没有"EXC_BAD_ACCESS“了。

如有任何答复和评论,将不胜感激。提前感谢!

编辑2

main.m

代码语言:javascript
运行
复制
#import <UIKit/UIKit.h>

#import "AppDelegate.h"

int main(int argc, char *argv[])
{
@autoreleasepool {
    return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
 // "EXC_BAD_ACCESS" error message shows here
}
}

编辑3:

这里声明了whereAmIAnnotation:

MapViewController.m

代码语言:javascript
运行
复制
@interface AddrCoordinateAdjustMapViewController()

@property (retain) WhereAmIAnnotation *whereAmIAnnotation;

@end
@implementation MapViewController
@synthesize whereAmIAnnotation;

编辑4:

错误消息如下:

代码语言:javascript
运行
复制
2012-07-30 15:56:19.735 myApp[13584:707] *** -[MapViewController respondsToSelector:]: message sent to deallocated instance 0x10195e80

当我切换回tableView时,当annotationView下降时,它通常会崩溃。

EN

Stack Overflow用户

发布于 2014-11-18 08:39:39

我也有类似的问题,我的解决方案是在从UINavigationController中弹出控制器之前从地图中删除所有的覆盖。我在用OpenStreetMap。

票数 0
EN
查看全部 4 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10893808

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档