簡體   English   中英

顯示當前位置MKMapView

[英]shows the current location MKMapView

我已經設置好了,以便我的MKMapView顯示當前位置。 我還為其他引腳實現了自定義引腳。 但是,事實證明當前位置顯示為自定義圖釘,而我只是希望它是一個常規的藍色圓圈(如google地圖所具有的)。

我在代碼中定義了以下內容:

- (MKAnnotationView *) mapView: (MKMapView *) mapView viewForAnnotation: (id<MKAnnotation>) annotation MKAnnotationView *pin = (MKAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: @"VoteSpotPin"];
    if (pin == nil)
    {
        pin = [[[MKAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"TestPin"] autorelease];
    }
    else
    {
        pin.annotation = annotation;
    }

    [pin setImage:[UIImage imageNamed:@"TestPin.png"]];
    pin.canShowCallout = YES;
    pin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    return pin;
}

如何防止當前位置顯示為大頭針?

嘗試這個 :-

- (MKAnnotationView *) mapView: (MKMapView *) mapView viewForAnnotation:(id<MKAnnotation>) annotation
{        
    if (annotation == mapView.userLocation)
    {
       return nil;
    }
    else
    {
       MKAnnotationView *pin = (MKAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: @"VoteSpotPin"];
       if (pin == nil)
       {  
          pin = [[[MKAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"TestPin"] autorelease];
       }
       else
       {
          pin.annotation = annotation;
       }           

       [pin setImage:[UIImage imageNamed:@"TestPin.png"]];
       pin.canShowCallout = YES;
       pin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
       return pin;
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM