tıklandığında Özel annotationView görüntüleri pimleri dönmek

oy
2

Ben aşağıdaki kodu kullanarak (yerine varsayılan iğnelerden) bir harita üzerinde özel görüntüler sergileyen ediyorum. Ben bir öğe üzerinde dokunun (ve çizgisi görünür) Ancak, görüntü varsayılan kırmızı iğne geri döner. Nasıl çizgisi görüntülenir bile, benim özel bir resim tutabilir?

- (MKAnnotationView *) mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
    MKPinAnnotationView *pinAnnotation = nil;

    if (annotation != mapView.userLocation) 
    {
        static NSString *pinID = @mapPin;
        pinAnnotation = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:pinID];
        if (pinAnnotation == nil)
            pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pinID] autorelease];

        // Set the image
        pinAnnotation.image = [UIImage imageNamed:@TestIcon.png];

        // Set ability to show callout
        pinAnnotation.canShowCallout = YES;

        // Set up the disclosure button on the right side
        UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        pinAnnotation.rightCalloutAccessoryView = infoButton;

        [pinID release];
    }

    return pinAnnotation;
    [pinAnnotation release];
}
Oluştur 05/04/2010 saat 00:08
kaynak kullanıcı
Diğer dillerde...                            


2 cevaplar

oy
5

Ben pinAnnotation bir MKAnnotationView yerine MKPinAnnotationView yaparak buldum, istenilen sonucu aldık. Görüntü artık bir iğne dönüşmez

    static NSString *pinID = @"mapPin";
    pinAnnotation = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:pinID];
    if (pinAnnotation == nil)
        pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pinID] autorelease];

    // Set the image
    pinAnnotation.image = [UIImage imageNamed:@"TestIcon.png"];
Cevap 23/11/2010 saat 08:47
kaynak kullanıcı

oy
0

Sen resim özelliği yerine bir subview kullanmak gerekir. Bu kod succssfully benim için sorunu çözer:

    UIImage * image = [UIImage imageNamed:@"blue_pin.png"];
    UIImageView *imageView = [[[UIImageView alloc] initWithImage:image] autorelease];
    [annView addSubview:imageView];
Cevap 20/05/2010 saat 12:53
kaynak kullanıcı

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more