我在地图上有一个注释。当我选择一个注释时,我会显示一个带有自定义视图的气泡。现在,当我点击气泡时,我想跳转到新的视图控制器,但是当我点击视图时,气泡视图就消失了。
-(void)mapView:(MKMapView *)mapView1 didSelectAnnotationView:(MKAnnotationView *)view
{
NSLog(@"selected");
if(![view.annotation isKindOfClass:[MKUserLocation class]])
{
CustomInfoWindow *calloutView = [[[NSBundle mainBundle]
loadNibNamed:@"infoWindow"owner:self options:nil] objectAtIndex:0];
CGRect calloutViewFrame = calloutView.frame;
calloutViewFrame.origin = CGPointMake(-calloutViewFrame.size.width/2 + 15, -calloutViewFrame.size.height);
calloutView.frame = calloutViewFrame;
[calloutView.imagePlace.layer setBorderColor: [[UIColor orangeColor] CGColor]];
[calloutView.imagePlace.layer setBorderWidth: 3.0];
NSData* imageData = [[NSData alloc] initWithContentsOfURL:
[NSURL URLWithString:@"http://farm3.staticflickr.com/2926/14605349699_67a1d51b80.jpg"]];
UIImage* image = [[UIImage alloc] initWithData:imageData];
[calloutView.imagePlace setImage:image];
[view addSubview:calloutView];
}
}
-(void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view
{
for (UIView *subview in view.subviews ){
[subview removeFromSuperview];
}
}