Shashwat Tyagi Shashwat Tyagi - 1 year ago 97
Objective-C Question

ios Custom annotation view using storyboard in MapKit

I'm trying to add a custom annotation view in mapkit.When I tap on red annotation pin , I got an annotation callout,but it is very simple.I want to add a custom view which I have made in the storyboard.
Can you please provide me a video or text tutorial link or any other kind of help regarding the same.

-(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]; = @"OpTi";
cpa.imgName1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"loc.png"]]; =;
self.customCallOutDetailsView.callImage = cpa.imgName1;

[self.view addSubview:self.customCallOutDetailsView];


My customCallOutDetailView is showing on tapping the annotation,but it's not showing at that annotation pin point,i think the view is taking its coordinates from the origin of the view.


In this method you can add you custom view.

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

 [view addSubview:customView];

More information on the following link : How To add custom View in map's Annotation's Callout's