MKMapView causes EXC_BAD_ACCESS when testing only

瘦欲@ 提交于 2019-12-13 05:23:38

问题


when testing on device only, i am getting EXC_BAD_ACCESS. This does not happen when i just run the app. I am concerned my users will experience the crash even though i am not when not testing. Anyone have any ideas why? It does not seem related to my annotations, as i comment out the adding of annotations and it still crashes.

Also, it loads on first view of the map, but when i navigate back to my collection view , then back to this view is when it crashes. My coordinates also seem valid since it passes the validity check.

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


I found on this question the answer which solved my problem. UIWebView EXC_BAD_ACCESS crash.

Product -> Edit Scheme -> Run -> Options -> Set GPU Frame Capture to Disabled.



来源:https://stackoverflow.com/questions/33321305/mkmapview-causes-exc-bad-access-when-testing-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!