I am having a little bit problem on the MapView.
First of all, no matter how i set the color of the pin, it remains red.
Secondly, there is no animation of drop pin, the pin just appear together with the UIView
Here is my code.
Thank you very much.
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
self->mapView.mapType = MKMapTypeHybrid;
CLLocationCoordinate2D center;
center.latitude = 33.79518;
center.longitude = 130.92263;
//declare span of map (height and width in degrees)
MKCoordinateSpan span;
span.latitudeDelta = .05;
span.longitudeDelta = .01;
//add center and span to a region,
//adjust the region to fit in the mapview
//and assign to mapview region
MKCoordinateRegion region;
region.center = center;
region.span = span;
mapView.region = [mapView regionThatFits:region];
transportfu *addAnnotation = [[transportfu alloc] initWithCoordinate:center];
[addAnnotation setTitle:@"City"];
[addAnnotation setSubTitle:@"Fukuoka"];
[mapView addAnnotation:addAnnotation];
[super viewDidLoad];
mapView.showsUserLocation = YES;
}
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MyPin"];
annView.canShowCallout = YES;
[annView setSelected:YES];
annView.pinColor = MKPinAnnotationColorGreen;
annView.calloutOffset = CGPointMake(-5, 5);
annView.animatesDrop=YES;
return annView;
}
Your
viewForAnnotationmethod needs a dequeue method.Try this: