Automatyczny „canShowCallOut” adnotacja IPHONE

głosy
4

W Wich sposób mogę wywołać funkcję, która otworzy się automatycznie mój adnotacji (z tytuł, napisy itp), zamiast poruszyć adnotacji na MapView?

Utwórz 20/03/2010 o 17:36
źródło użytkownik
W innych językach...                            


2 odpowiedzi

głosy
4

Wdrożenie MKMapViewDelegatedelegata;

wdrożenia - (MKAnnotationView *) mapView: (MKMapView *) mapView_ viewForAnnotation: (id <MKAnnotation>) annotation_;; na przykład tak:

    - (MKAnnotationView *) mapView: (MKMapView *) mapView_ viewForAnnotation: (id <MKAnnotation>) annotation_ {

    MKPinAnnotationView *pin = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: @"YourPinId"];
    if (pin == nil) {
        pin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation_ reuseIdentifier: @"YourPinId"] autorelease];
    }
    else {
        pin.annotation = annotation_;
    }
    pin.pinColor = MKPinAnnotationColorRed;
    [pin setCanShowCallout:YES];
    pin.animatesDrop = YES;
    return pin;
}

Pokaż na mapie pin po zakończeniu ładowania:

- (void) dropPin {
    [mapView addAnnotation:self.annotation];
    [mapView selectAnnotation:self.annotation animated:YES];        
}

- (void) mapViewDidFinishLoadingMap: (MKMapView *) mapView_ {
    // if done loading, show the call out
    [self performSelector:@selector(dropPin) withObject:nil afterDelay:0.3];
}

Kod ten ma właściwość o nazwie adnotację, która implementuje MKAnnotation. Ponadto, animuje muche też, ale powinien on być dość self-wyjaśniając.

HTH.

Odpowiedział 21/03/2010 o 21:47
źródło użytkownik

głosy
3

Alfons odpowiedział na pytanie, ale jeśli szukasz co dokładnie automatycznie otwiera objaśnienie, to ta część:

[mapView selectAnnotation:annotation animated:YES]; 
Odpowiedział 10/01/2012 o 05:09
źródło użytkownik

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