MKPinAnnotationView is a subclass of MKAnnotationView.
MKAnnotationView is a generic annotation view for which you have to provide the image and animation if desired.
MKPinAnnotationView is a convenient subclass of MKAnnotationView which automatically provides a pin image in a selected color and an animation of the pin dropping onto the map. You set the animatesDrop property when creating the view in viewForAnnotation and it will handle the animation automatically from there.
If you don't implement viewForAnnotation, a standard red pin with no animation is displayed.
By the time didAddAnnotationViews is called, the automatic animation has already happened and setting that property there has no effect.
If however you want to create a custom animation different from the default drop animation that MKPinAnnotationView provides, you could do that in didAddAnnotationViews. The view will already be at its final destination point so you save that and then animate it from a different point to that destination.
If you're happy with the default drop animation that MKPinAnnotationView provides, you don't need to implement didAddAnnotationViews. That delegate method is more useful for doing other things that you might need to do when all the annotation views are actually in place.
For your pins to show the title, set canShowCallout
to YES
where you set animatesDrop
.
Not sure what you mean by "this creates a new set of MKAnnotationViews". In the viewForAnnotation method, you are providing a view (MKPinAnnotationView) for the MKAnnotation object. They are not the same thing.
Also, the viewForAnnotation method works like the cellForRowAtIndexPath method for UITableView where annotation views can get recycled which is why it's important to set MKAnnotation-specific information in the view every time (such as the annotation property).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…