MKMapView несколько аннотаций вызывать кнопки для подробного просмотра - PullRequest
0 голосов
/ 18 июня 2011

Я занимаюсь разработкой приложения для локального поиска, такого как рестораны и т. Д., Используя это приложение http://www.totagogo.com/2011/02/08/google-local-search-ios-code/, и я собираюсь применять кнопки для вызова аннотаций для извлечения деталей путем перехода к другому detailViewController. Пожалуйста, помогите мне преодолеть эту проблему, предоставив несколько учебных пособий / примеров кода.

1 Ответ

0 голосов
/ 24 июня 2011

Я получил решение

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(GoogleLocalObject *) annotation 
{

    static NSString* AnnotationIdentifier = @"AnnotationIdentifier";


    MKPinAnnotationView* customPinView = [[[MKPinAnnotationView alloc]
                                           initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease];
    customPinView.pinColor = MKPinAnnotationColorRed;
    customPinView.animatesDrop = YES;
    customPinView.canShowCallout = YES;

    UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    [rightButton addTarget:self
                    action:@selector(showDetails:)
          forControlEvents:UIControlEventTouchUpInside];
    customPinView.rightCalloutAccessoryView = rightButton;

    UIImageView *memorialIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"googlemaps_pin.png"]];
    customPinView.leftCalloutAccessoryView = memorialIcon;
    [memorialIcon release];

    return customPinView;


}

- (void)showDetails:(id)sender {
    GoogleLocalObject *obj;
    for (int i = 0; i < [objectsFromGoogle count]; i++) {
        obj = [objectsFromGoogle objectAtIndex:i];
    }

    self.reverseGeocoder =
    [[[MKReverseGeocoder alloc] initWithCoordinate:obj.coordinate] autorelease];
    reverseGeocoder.delegate = self;
    [reverseGeocoder start];
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...