簡體   English   中英

MKAnnotation image屬性的問題

[英]issue with with MKAnnotation image property

我正在實現一個基於MKMapView的應用程序。 在這種情況下,我使用自定義圖像,而不是通過使用MKAnnotationView.Image屬性來顯示圖釘。 它不起作用。 它始終以紅色顯示標准圖釘,但也沒有顯示我指向的圖像。 有任何想法嗎?

- (void)setPin:(MKPinAnnotationView *)aPin forAnnotation:(id <MKAnnotation>)anAnnotation {
    if (anAnnotation == self.userAnnotation) {

        aPin.image = [UIImage imageNamed:@"youarehere.png"];
        aPin.opaque = NO;

        aPin.pinColor = MKPinAnnotationColorRed;
    }
}

如果像您一樣使用MKPinAnnotationView ,那么您將無法僅將圖像設置為pinColor。 MKPinAnnotationView只有pinColoranimatesDrop的性能。

您想使用父類MKAnnotationView 它可以讓您設置圖像。

閱讀每個類的類參考,它將很有意義。 這是Objective-C令我發瘋的時候之一,因為當您在文檔中閱讀那些冗長的類名時,可以很容易地在類名的“ Pin”變體中進行掃描。

暫無
暫無

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

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