ios - MKMapView 仅在测试时导致 EXC_BAD_ACCESS

标签 ios iphone debugging mkmapview exc-bad-access

仅在设备上测试时,我收到 EXC_BAD_ACCESS。当我运行应用程序时不会发生这种情况。我担心我的用户会遇到崩溃,即使我没有在不测试时遇到崩溃。任何人有任何想法为什么?它似乎与我的注释无关,因为我注释掉了注释的添加并且它仍然崩溃。

此外,它加载到 map 的第一个 View ,但是当我导航回我的收藏 View 时,然后返回到该 View 时它崩溃了。我的坐标似乎也有效,因为它通过了有效性检查。

        //////THIS IS ALL THE MAP VIEW STUFF......
        self.mapView.delegate = self;
        self.mapView = [[MKMapView alloc] initWithFrame:CGRectMake(17, 650, 733, 300)];
        self.mapView.scrollEnabled = NO;
        self.mapView.zoomEnabled = NO;
        self.mapView.showsUserLocation = YES;

        CLLocationCoordinate2D location;                         
        NSMutableArray *newAnnotations = [NSMutableArray array]; 
        MKPointAnnotation *newAnnotation;                        

        location.latitude = [[_selectedCategoryItem objectForKey:@"latitude"]doubleValue];
        location.longitude = [[_selectedCategoryItem objectForKey:@"longitude"]doubleValue];

        NSLog(@"Latitude ==> %f", [[_selectedCategoryItem objectForKey:@"latitude"]doubleValue]);
        NSLog(@"Longitude ==> %f", [[_selectedCategoryItem objectForKey:@"longitude"]doubleValue]);

        newAnnotation = [[MKPointAnnotation alloc] init];
        newAnnotation.coordinate = location;

        MKCoordinateRegion region;
        MKCoordinateSpan span;
        span.latitudeDelta = 0.10;
        span.longitudeDelta = 0.10;
        region.span = span;
        region.center = location;

        if (CLLocationCoordinate2DIsValid(location)) {

            NSLog(@"place has VALID coordinates");
            [newAnnotations addObject:newAnnotation];
            [self.mapView addAnnotations:newAnnotations];

        } else {

            NSLog(@"place has INVALID coordinates");
        }

        [self.mapView setRegion:region animated:TRUE];
        [self.m_ScrollView addSubview:self.mapView];

        /////END ALL THE MAP VIEW STUFF//////////

最佳答案

我在这个问题上找到了解决我问题的答案。 UIWebView EXC_BAD_ACCESS crash .

产品 -> 编辑方案 -> 运行 -> 选项 -> 将 GPU 帧捕获设置为禁用。

关于ios - MKMapView 仅在测试时导致 EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33321305/

相关文章:

ios - 制作配置文件后,找不到代码签名

iphone - 为重叠的 UI 对象绘制阴影

iphone - 将代码提交到 SVN 服务器时更改工作副本路径。

android - 使用 React Native 在 VS Code 中使用断点调试 Jest 单元测试

ios - 检测长按tableview

ios - 将物理体锁定到 X 轴 Spritekit Swift

ios - iOS 13,什么时候保存数据?

ios - 查找存储在NSDictionary中的值的索引和存储在NSMutableArray中的NSDictionary的值的索引

c++ - 在类或结构中使用未设置的成员变量

asp.net-mvc - 我如何使用新的 Phil 的 routedebugger