Mapview - 导航控制器

时间:2014-02-19 08:10:00

标签: ios objective-c annotations mkmapview navigationcontroller

我正在使用MKMapView进行IOS应用 我使用导航控制器从主菜单转到mapview,再从mapview返回主菜单。这个工作正常! 但是,如果我在地图上删除一些注释并按下后退按钮,则应用程序每次都会崩溃。

在xcode的调试导航器中,出现以下错误: lldb_unnamed_function1128$$CoreLocation

Crashlytics的一些信息:

0
CoreLocation    
CLClientCreateIso6709Notation + 31645
1
libobjc.A.dylib 
objc_object::sidetable_release(bool) + 174
2
libobjc.A.dylib 
objc_object::sidetable_release(bool) + 174
3
MapKit  
std::__1::__vector_base<objc_object* __strong, std::__1::allocator<objc_object* __strong> >::~__vector_base() + 28
4
MapKit  
MKQuadTrieNodeFree(MKQuadTrieNode*) + 32
5
MapKit  
__38-[MKQuadTrie clearAllItemsPerforming:]_block_invoke + 72
6
MapKit  
_breadthFirstApply(MKQuadTrieNode*, MKQuadTrieTraversalDirective ()(MKQuadTrieNode*) block_pointer) + 186
7
MapKit  
-[MKQuadTrie clearAllItemsPerforming:] + 166

什么是lldb_unnamed_function1128$$CoreLocation错误

有人可以帮忙吗? :)

我的后退按钮代码:

- (IBAction)backPressed:(id)sender {
    [self.mapView removeAnnotations:self.mapView.annotations];
    [self.mapView removeOverlays:self.mapView.overlays];
    self.locationManager.delegate = nil;
    self.mapView.delegate = nil;
     NSLog(@"Done!");
}

viewForAnnotation代码:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {

    if (annotation == mapView.userLocation) {
        return nil; // Let map view handle user location annotation
    }

    // Identifyer for reusing annotationviews
    static NSString *annotationIdentifier = @"icon_annotation";

    // Check in queue if there is an annotation view we already can use, else create a new one
    IconAnnotationView *annotationView = (IconAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
    if (!annotationView) {
        annotationView = [[IconAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotationIdentifier];
        annotationView.canShowCallout = YES;
        annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    }

    return annotationView;

}

添加注释的代码(名为重新加载按钮):

- (IBAction)reload:(id)sender {


    [self.mapView removeOverlays:self.mapView.overlays];

    if (!userPressedReload) {

        self.parkPlace1 = [[Place alloc] initWithLong:40.975301  Lat:22.069451 iconStatus:[NSNumber numberWithInt:2] beforeMin:[NSNumber numberWithInt:10]];
        self.parkPlace2 = [[Place alloc] initWithLong:40.981507 Lat:22.057485 iconStatus:[NSNumber numberWithInt:1] beforeMin:[NSNumber numberWithInt:20]];
        [self.mapView addAnnotation:self.parkPlace1];
        [self.mapView addAnnotation:self.parkPlace2];

        userPressedReload = YES;
    }

      self.annotations = [NSMutableArray arrayWithArray:self.mapView.annotations];
    if (self.mapView.userLocation) {
        [self.annotations removeObject:self.mapView.userLocation];
    }

    [self.mapView removeAnnotations:self.annotations];
    [self.mapView addAnnotations:self.annotations];

}

0 个答案:

没有答案