Reputation: 1976
In my mapview, I currently have the bool animatesDrop for the annotations set to NO. This is because when the mapView annotations are plotted during viewWillAppear, I don't when them animated. However, I also have a refresh button used to re-plot the annotations and would like them to animated (drop) when that is pushed. Is there a way of accomplishing this? Thanks.
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
if ([annotation isKindOfClass:[MKUserLocation class]]) {
return nil;
}
MyPin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"current"];
UIButton *calloutButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
UIButton *directionsButton = [UIButton buttonWithType:UIButtonTypeCustom];
directionsButton.frame = CGRectMake(0, 0, 23, 23);
[directionsButton setBackgroundImage:[UIImage imageNamed:@"directions.png"] forState:UIControlStateNormal];
MyPin.leftCalloutAccessoryView = directionsButton;
MyPin.rightCalloutAccessoryView = calloutButton;
MyPin.draggable = NO;
MyPin.highlighted = NO;
MyPin.animatesDrop= YES;
MyPin.canShowCallout = YES;
return MyPin;
}
Upvotes: 0
Views: 344
Reputation: 5268
Remove all your annotation using the code
[self.mapView removeAnnotations:self.usersAnnotationArray];
And annotation once again to mapview , check button click using BOOL
variable and set
MyPin.animatesDrop= YES;
in delagate method
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
......
......
......
if(_IsButtonClikced)
{
MyPin.animatesDrop= YES;
}
else
{
MyPin.animatesDrop= NO;
}
................
.......
.....
}
Upvotes: 0
Reputation: 171
"Hard Ball" approach would be to establish a boolean property that is set to false in viewWillAppear, but set to true in your button's action. set MyPin.animatesDrop to the property in viewForAnnotation. Don't know of any "elegant" solution.
Upvotes: 2