在Iphone SDK的地图的细节视图

时间:2013-01-23 12:22:50

标签: iphone ios objective-c xcode mkmapview

在我的应用中,我实施了一个地图View&添加了注释。

但是现在,我想在popover中显示点击注释的详细视图。现在,我点击了calloutAccessoryControl。

但是popover必须从注释旁边开始。  我不想显示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];

}

点击注释时是否有任何方法调用?

我该怎么做?

**我想这样表现**

enter image description here

1 个答案:

答案 0 :(得分:1)

在实现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
    }
}