title: The simplest way to add a pin on a map in iOS
body: <p>Suppose I have the code below to add a map on a view, what is the <strong>simplest</strong> way to add a <strong>pin</strong> on the location. Could someone advise the code snippet to add to my code?</p>
  
  <p>Thanks</p>
  
  <pre><code>- (void)viewDidLoad
  {
      MKMapView *map = [[MKMapView alloc] initWithFrame:CGRectMake(2, 2, 300, 300)];
      MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
  
      region.center.latitude = 22.278355;
      region.center.longitude = 114.181713;
  
      region.span.longitudeDelta = 0.01f;
      region.span.latitudeDelta = 0.01f;  
  
      [map setRegion:region animated:YES];
      [map regionThatFits:region];
  
      [self.view addSubview:map];
      [super viewDidLoad];
      // Do any additional setup after loading the view from its nib.
  }
  </code></pre>
  
  <p>UPDATE: </p>
  
  <p>xxx.h</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import &lt;MapKit/MapKit.h&gt;
  
  
  @interface ShopDetail : UIViewController &lt;MKMapViewDelegate&gt; {
  
  }
  
  @end
  </code></pre>
  
  <p>xxx.m</p>
  
  <pre><code>- (void)viewDidLoad
  {
      MKMapView *map = [[MKMapView alloc] initWithFrame:CGRectMake(2, 2, 300, 300)];
      MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
  
      region.center.latitude = 22.278355; //40.105085;
      region.center.longitude = 114.181713; //-83.005237;
  
      region.span.longitudeDelta = 0.01f;
      region.span.latitudeDelta = 0.01f;  
  
      [map setRegion:region animated:YES];
      [map regionThatFits:region];
  
      map.delegate = self;
  
      [self.view addSubview:map];
  
      [super viewDidLoad];
      // Do any additional setup after loading the view from its nib.
  }
  
  - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id &lt;MKAnnotation&gt;)annotation {
      MKPinAnnotationView *pav = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil];
  
      NSLog(@"called viewForAnnotation");
  
      pav.pinColor = MKPinAnnotationColorGreen;
      return pav;
  }
  </code></pre>
  
  <p>*NSLog(@"called viewForAnnotation"); has not been executing.</p>