我正在尝试在 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 在点击注释时显示,但它没有在该注释针点处显示,我认为视图正在从视图的原点获取其坐标。