繁体   English   中英

由于未捕获的异常“ NSInvalidArgumentException”而终止应用程序,原因:“-[MKUserLocation标记]:

[英]Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MKUserLocation tag]:

我只是比较两个值,但有时应用程序崩溃。 如何处理。

NSString *  markerid = [_selectedCoordinate objectForKey:@"markerid"];
    for(CustomAnnotations *annotation in _mapView.annotations){
        if(annotation.tag == [markerid integerValue]){
            [_mapView selectAnnotation:annotation animated:NO];
            return;
        }
    }

地图注释也包含用户位置注释,请检查[annotation class] != [MKUserLocation class][annotation class] == [CustomAnnoation class]然后获取注释的标签

NSString *  markerid = [_selectedCoordinate objectForKey:@"markerid"];
for(CustomAnnotations *annotation in _mapView.annotations){
    if([annotation class] != [MKUserLocation class]) {
        if(annotation.tag == [markerid integerValue]) {
            [_mapView selectAnnotation:annotation animated:NO];
            return;
        }
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM