在我的 map View 中,我目前将注释的 bool animatesDrop 设置为 NO。这是因为当 mapView 注释在 viewWillAppear 期间绘制时,我不会在它们动画时显示。但是,我还有一个刷新按钮用于重新绘制注释,并希望它们在按下时动画化(放下)。有没有办法做到这一点?谢谢。
-(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;
}
最佳答案
“硬球”方法是建立一个 bool 属性,该属性在 viewWillAppear 中设置为 false,但在按钮的操作中设置为 true。将 MyPin.animatesDrop 设置为 viewForAnnotation 中的属性。不知道有什么“优雅”的解决方案。
关于iOS mapView animatesDrop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15890854/