1

我在我的应用程序中实现了一个地图视图。

我实现了一个 didselect 注释方法。

在这种方法中,我打开一个弹出窗口。它工作正常。但是当弹出框被关闭并尝试再次单击注释时,则不再调用方法。

如果我单击了除先前选择注释之外的其他注释,则将调用该方法。

我的代码如下:

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)aView {



    ReadingDatabaseAppDelegate *appDelegate = (ReadingDatabaseAppDelegate *)[[UIApplication sharedApplication] delegate];

    if([self isPad])
    {
        detailsView *popUp=[[detailsView alloc] initWithNibName:@"detailsView_ipad" bundle:nil];


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

        popView.delegate =self;

        [popView setPopoverContentSize:CGSizeMake(400, 400)];




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

        NSLog(@"%d",popUp.locationID);

        popUp.list=listdata;
        detView.fromMapView = TRUE;

        if (appDelegate.preferenceRow == 1) {
            detView.title = @"ATM Details";
            popUp.isBranch = 0;
        }
        else {
            detView.title = @"Branch Details";
            popUp.isBranch = 1;
        }




        CGPoint annotationPoint = [mapView convertCoordinate:aView.annotation.coordinate toPointToView:mapView];
        float boxDY=annotationPoint.y;
        float boxDX=annotationPoint.x;
        CGRect box = CGRectMake(boxDX,boxDY,5,5);
        UILabel *displayLabel = [[UILabel alloc] initWithFrame:box];


        [popView presentPopoverFromRect:displayLabel.frame inView:mapView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
        [displayLabel release];



    }

}

** 我该如何解决这个问题??**

4

1 回答 1

10

当您关闭弹出框时,使用 取消选择注释-deselectAnnotation:animated:

于 2013-01-24T11:37:13.477 回答