Monotouch MapKit - 注释 - 为泡泡添加按钮 [英] Monotouch MapKit - annotations - adding a button to bubble

查看:128
本文介绍了Monotouch MapKit - 注释 - 为泡泡添加按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道是否有按钮上的注释?

Anyone know if there's anyway to get a button onto an annotation?

我希望这个位置可以选择 - 所以你可以说..选择位置并通过单击按钮获取该位置的所有事件。

I'd like the location to be selectable - so you can say.. select the location and get all the events at that location by clicking on the button.

这可能吗?

w://

推荐答案

这是我用于注释的代码,它包含一个位于气泡右侧的按钮。您可以设置IBAction将新视图推送到堆栈以显示您想要的任何内容

Here's the code I used for my annotation, it includes a button on the right side of the bubble. You can set an IBAction to push a new view onto the stack to display whatever you want

- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation
{
    MKPinAnnotationView *pinAnnotation = nil;
    if(annotation != mapView.userLocation) 
    {
        static NSString *defaultPinID = @"myPin";
        pinAnnotation = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
        if ( pinAnnotation == nil )
            pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];

        pinAnnotation.canShowCallout = YES;

        //instatiate a detail-disclosure button and set it to appear on right side of annotation
        UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        pinAnnotation.rightCalloutAccessoryView = infoButton;

    }

    return pinAnnotation;
}

这篇关于Monotouch MapKit - 注释 - 为泡泡添加按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆