0

I try to make a pin annotation to drop in MapView . But it doesn't .

The view controller has one table view and I plug mapView into the header.

DetailViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
 self.title = @"Nearby";

  //coord is CLLocationCoordinate2D which is instance variable 

 ItemMapPoint *itemMapPoint = [[SquakItemMapPoint alloc] initWithCoordinate:coord title:@"Test"];
[mapView addAnnotation:itemMapPoint];


MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coord, 500, 500);
[mapView setRegion:region animated:YES];
//the delegate is not set here but I set it in Interface Builder

self.tableView.tableHeaderView = mapView;

}
/this is delegate method to set Pin to drop 
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id     <MKAnnotation>)annotation
{
  MKPinAnnotationView *annoView = [[MKPinAnnotationView alloc]
 initWithAnnotation:annotation
 reuseIdentifier:@"current"];  


annoView.animatesDrop = YES;
annoView.pinColor = MKPinAnnotationColorGreen;
return annoView;
}

Pin is green as I set in the delegate but Pin does not drop when the screen load. I tried to change the code to ViewDidAppear() also but it still does not work.

Please help .

Thanks in Advance

Kong Hantrakool
  • 1,865
  • 3
  • 20
  • 35
  • 1
    I'm not totally familiar with annotations yet, but maybe try adding it after the map has finished loading, using the delegate function mapViewDidFinishLoadingMap: – Lewis Gordon Apr 02 '13 at 11:00

1 Answers1

0

Two things-

  1. Make sure ur ItemMapPoint and SquakItemMapPoint implement the needed protocols.

  2. Try adding the mapView i.e. self.tableView.tableHeaderView = mapView; before u add annotation(s) i.e. [mapView addAnnotation:itemMapPoint];.

Ishank
  • 2,860
  • 32
  • 43