在我的应用程序中,我实现了地图视图并添加了注释。

但是现在,我想在popover中单击注解时显示详细视图。直到现在,我还是在calloutAccessoryControl单击时执行此操作。

但是弹出窗口必须以注解&开头
 我不想显示calloutAccessoryControl或任何黑色的默认标签。

我的代码是:

- (MKAnnotationView *)mapView:(MKMapView *)myMap viewForAnnotation:(id <MKAnnotation>)annotation
{
AnnotationImageView *myLocationImage = (AnnotationImageView *)[map dequeueReusableAnnotationViewWithIdentifier:defaultID];

    if (myLocationImage == nil )
    {
        myLocationImage = [[[AnnotationImageView alloc] initWithAnnotation:annotation reuseIdentifier:defaultID] autorelease];
        myLocationImage.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    }

    myLocationImage.locationID = [currentAnnotation locationID];
    myLocation = myLocationImage;

    [myLocation setEnabled:YES];
    [myLocation setCanShowCallout:YES];

    return myLocation;
}


- (void)mapView:(MKMapView *)myMap annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{

detailsView *popUp=[[detailsView alloc] initWithNibName:@"detailsView_ipad" bundle:nil];


        popView = [[UIPopoverController alloc]initWithContentViewController:popUp];

        popView.delegate =self;

        [popView setPopoverContentSize:CGSizeMake(600, 500)];



AnnotationImageView *myLocationImage = (AnnotationImageView *)view;
        popUp.locationID = myLocationImage.locationID;

[popView presentPopoverFromRect:control.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

}


单击注解时是否有任何方法调用?

我怎样才能做到这一点??

**我想这样显示**

最佳答案

在实现MKMapViewDelegate的类中,可以实现mapView:didSelectAnnotationView:方法:

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)aView {
    //do something...like push a new UIViewController

    if (UIUserInterfaceIdiomPhone == UI_USER_INTERFACE_IDIOM()) {
        //only do something when the app is running on the iPhone
    }
}

关于iphone - Iphone SDK中的 map 上的局部 View ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14479644/

10-10 02:18