开发者

MKMapView multiple annotation call out buttons to detail view

开发者 https://www.devze.com 2023-03-14 06:15 出处:网络
I am developing an app for local search like Restaurants e开发者_如何学Gotc., by making use of this app http://www.totagogo.com/2011/02/08/google-local-search-ios-code/ and I am struct to apply button

I am developing an app for local search like Restaurants e开发者_如何学Gotc., by making use of this app http://www.totagogo.com/2011/02/08/google-local-search-ios-code/ and I am struct to apply buttons to call out of annotations to extract details by navigating to another detailViewController. please help me to overcome this problem by giving some tutorials / sample code.


I got the solution

- (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];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号