MKMapView 多个注释调出按钮到详细视图

发布于 2024-11-16 04:56:49 字数 293 浏览 1 评论 0 原文

我正在开发一个用于本地搜索的应用程序,例如餐厅等,通过使用此应用程序 http://www.totagogo.com/2011/02/08/google-local-search-ios-code/ 我打算应用按钮来调出注释通过导航到另一个detailViewController来提取详细信息。请通过提供一些教程/示例代码来帮助我克服这个问题。

I am developing an app for local search like Restaurants etc., 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画离情绘悲伤 2024-11-23 04:56:49

我得到了解决方案

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

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];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文