MKMapView仅在测试时导致EXC_BAD_ACCESS

时间:2015-10-24 17:40:57

标签: ios iphone debugging mkmapview exc-bad-access

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

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

        //////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//////////

1 个答案:

答案 0 :(得分:4)

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

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