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