我在我的应用中实现了地图视图。
我实现了一个didselect注释方法。
在这种方法中,我打开一个弹出窗口。它工作正常。但是当popover被解雇时尝试再次单击注释,然后不再调用方法。
如果我点击其他注释,除了先前选择注释,那么将调用方法。
我的代码如下:
- (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];
}
}
**我怎样才能解决这个问题?**
答案 0 :(得分:10)
当您关闭弹出窗口时,请使用-deselectAnnotation:animated:
取消选择注释。