簡體   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