0

我想在mapkit中添加一个自定义注释视图。当我点击红色注释引脚时,我得到了一个注释标注,但它非常简单。我想添加一个自定义视图,这是我在故事板中创建的。 你可以给我一个视频或文本教程链接或任何其他类型的帮助。ios使用MapKit中的故事板自定义注释视图

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

    if([view isKindOfClass:[MKUserLocation class]]){ 

     return ; 
    } 

    CLLocationCoordinate2D optimusInfoCallOut = CLLocationCoordinate2DMake(28.625551, 77.373268); 

    [self.mapView setRegion:MKCoordinateRegionMakeWithDistance(optimusInfoCallOut, 800, 800)animated:YES]; 

    UIImageView *imgView =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"loc.png"]]; 

    CGRect calloutViewFrame = imgView.frame; 
    imgView.frame = CGRectMake(calloutViewFrame.size.width/8.0, calloutViewFrame.size.height-24, 200, 100); 

    CustomPointAnnotation *cpa = [[CustomPointAnnotation alloc] init]; 
    cpa.name = @"OpTi"; 
    cpa.imgName1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"loc.png"]]; 
    self.customCallOutDetailsView.name.text = cpa.name; 
    self.customCallOutDetailsView.callImage = cpa.imgName1; 

    [self.view addSubview:self.customCallOutDetailsView]; 
} 

我customCallOutDetailView是否显示在攻注解,但它不是在那个注释针点出,我觉得画面从视图的原点取它的坐标。

回答

0

在这种方法中,您可以添加自定义视图。以下链接

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

[view addSubview:customView]; 
} 

的更多信息: How To add custom View in map's Annotation's Callout's

+0

yup..It的工作 –

+0

我无法看到自定义在针点location.It叫出被显示在地图的右上角。 你能帮我解答吗?我也发布了我的代码。 –

+0

customView.center = CGPointMake(view.bounds.size.width * 0.5f,-self.visibleCalloutView.bounds.size.height * 0.5f); –

相关问题