Objective c 相当于;didAddAnnotationViews“;用于移除销?
我有地图视图。我已经实现了didAddAnnotationViews来为我的管脚显示自定义淡入动画Objective c 相当于;didAddAnnotationViews“;用于移除销?,objective-c,mkmapview,mkannotation,Objective C,Mkmapview,Mkannotation,我有地图视图。我已经实现了didAddAnnotationViews来为我的管脚显示自定义淡入动画 将接点添加到贴图时会成功调用,但移除接点时不会成功调用。我在文档中找不到等效函数。是否有其他方法可以为特定管脚实现自定义淡出动画?没有用于删除批注的委派方法,但可以通过以下方法实现动画效果: 如果要删除注释,请首先使用动画淡出其视图,并在动画完成后删除注释。您的代码可能如下所示: [UIView animateWithDuration:0.5f animations:^(void){
将接点添加到贴图时会成功调用,但移除接点时不会成功调用。我在文档中找不到等效函数。是否有其他方法可以为特定管脚实现自定义淡出动画?没有用于删除批注的委派方法,但可以通过以下方法实现动画效果: 如果要删除注释,请首先使用动画淡出其视图,并在动画完成后删除注释。您的代码可能如下所示:
[UIView animateWithDuration:0.5f animations:^(void){
annotationView.alpha = 0.0f;
}
completion:^(BOOL finished){
[mapView removeAnnotation:annotation];
}];
我使用以下方法创建了MKMapView的类别
- (void)removeAnnotation:(id<MKAnnotation>)annotation animated:(BOOL)shouldAnimate;
- (void)removeAnnotations:(NSArray *)annotations animated:(BOOL)shouldAnimate;
-(void)removeAnnotation:(id)annotation animated:(BOOL)shouldAnimated;
-(void)removeAnnotations:(NSArray*)已设置动画的批注:(BOOL)应设置动画;
你可以打电话而不是打电话
- (void)removeAnnotation:(id<MKAnnotation>)annotation;
- (void)removeAnnotations:(NSArray *)annotations;
-(void)删除注释:(id)注释;
-(void)删除注释:(NSArray*)注释;
以下是实现:
- (void)removeAnnotation:(id<MKAnnotation>)annotation animated:(BOOL)shouldAnimate {
if (!shouldAnimate)
[self removeAnnotation:annotation];
else {
MKAnnotationView *annotationView = [self viewForAnnotation:annotation];
CGRect endFrame = annotationView.frame;
endFrame = CGRectMake(
annotationView.frame.origin.x,
annotationView.frame.origin.y - self.bounds.size.height,
annotationView.frame.size.width,
annotationView.frame.size.height);
[UIView animateWithDuration:0.3
delay:0.0f
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
annotationView.frame = endFrame;
}
completion:^(BOOL finished) {
[self removeAnnotation:annotation];
}];
}
}
- (void)removeAnnotations:(NSArray *)annotations animated:(BOOL)shouldAnimate {
if (!shouldAnimate)
[self removeAnnotations:annotations];
else {
NSTimeInterval delay = 0.0;
for (id<MKAnnotation> annotation in annotations) {
MKAnnotationView *annotationView = [self viewForAnnotation:annotation];
CGRect endFrame = annotationView.frame;
endFrame = CGRectMake(
annotationView.frame.origin.x,
annotationView.frame.origin.y - self.bounds.size.height,
annotationView.frame.size.width,
annotationView.frame.size.height);
[UIView animateWithDuration:0.3
delay:delay
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
annotationView.frame = endFrame;
}
completion:^(BOOL finished) {
[self removeAnnotation:annotation];
}];
delay += 0.05;
}
}
}
-(void)removeAnnotation:(id)annotation animated:(BOOL)shouldAnimated{
如果(!shouldAnimate)
[自我移除注释:注释];
否则{
MKAnnotationView*annotationView=[注释的自视图:注释];
CGRect endFrame=annotationView.frame;
endFrame=CGRectMake(
annotationView.frame.origin.x,
annotationView.frame.origin.y-self.bounds.size.height,
annotationView.frame.size.width,
annotationView.frame.size.height);
[UIView animateWithDuration:0.3
延迟:0.0f
选项:UIViewAnimationOptionAllowUserInteraction
动画:^{
annotationView.frame=结束帧;
}
完成:^(布尔完成){
[自我移除注释:注释];
}];
}
}
-(void)removeAnnotations:(NSArray*)已设置动画的批注:(BOOL)应设置动画{
如果(!shouldAnimate)
[自我移除注释:注释];
否则{
NSTimeInterval延迟=0.0;
用于(注释中的id注释){
MKAnnotationView*annotationView=[注释的自视图:注释];
CGRect endFrame=annotationView.frame;
endFrame=CGRectMake(
annotationView.frame.origin.x,
annotationView.frame.origin.y-self.bounds.size.height,
annotationView.frame.size.width,
annotationView.frame.size.height);
[UIView animateWithDuration:0.3
延迟:延迟
选项:UIViewAnimationOptionAllowUserInteraction
动画:^{
annotationView.frame=结束帧;
}
完成:^(布尔完成){
[自我移除注释:注释];
}];
延迟+=0.05;
}
}
}
我也想知道这一点!如何获得annotationView?@Dima和viewForAnnotation:MKMapView中的方法