我只是比较两个值,但有时应用程序崩溃。如何处理。
NSString * markerid = [_selectedCoordinate objectForKey:@"markerid"];
for(CustomAnnotations *annotation in _mapView.annotations){
if(annotation.tag == [markerid integerValue]){
[_mapView selectAnnotation:annotation animated:NO];
return;
}
}
最佳答案
map 注释还包含用户位置注释,请检查[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;
}
}
}
关于ios - 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[MKUserLocation标记]:,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47410792/