user1673099
user1673099

Reputation: 3299

didSelectAnnotationView for map is called only once in iphone sdk

I implemented a map view in my app.

I implemented a didselect annotation method.

In this method,i open a popover. It works fine. But when the popover is dismiss & try to click on annotation again, then method is not called more.

if i clicked other annotation except previously select annotation then method will called.

My code is follow:

- (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];



    }

}

** How can i solve this??**

Upvotes: 1

Views: 2184

Answers (1)

nevan king
nevan king

Reputation: 113777

When you dismiss your popover, deselect the annotation using -deselectAnnotation:animated:.

Upvotes: 10

Related Questions