1

我想知道是否有任何方法可以在标注气泡中添加UITextField& a ,如果用户单击按钮,它会调用一些方法?UIButtonMKPinAnnotationView

4

1 回答 1

0

您可以添加自定义视图而不是MKAnnotationView 使用下面的代码..

您可以简单地添加任何具有addSubview属性的控件...

-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation 
{
    MKAnnotationView *customPinView = nil; 
    if(annotation != mapView.userLocation) 
    {
        static NSString *defaultPinID = @"com.invasivecode.pin";
        pinView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
        if ( customPinView == nil ) 
            customPinView = [[MKAnnotationView alloc]
                                         initWithAnnotation:annotation reuseIdentifier:defaultPinID];

        customPinView.canShowCallout = YES;
        //customPinView.animatesDrop = YES;
        customPinView.image = [UIImage imageNamed:@"yourImageName"];//write your imagename 
        // and add UIButton with bellow code
        UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        [rightButton addTarget:self
                            action:@selector(ShowStoreDetail:)
                  forControlEvents:UIControlEventTouchUpInside];
        customPinView.rightCalloutAccessoryView = rightButton;here
    } 
    else {
        [mapView.userLocation setTitle:@"I am here"];
    }
    return pinView;
}

我希望它对你有用...

:)

于 2013-05-23T07:21:30.190 回答