Ios 如何在点击MKPinAnnotationView时为注释添加动画?
我在地图视图中有一个自定义pin,我需要在点击时放大pin,然后在按下其他pin时返回默认大小,就像foursquare应用程序一样 这是我用来放大它的代码,但是当我点击另一个引脚时,如何将它返回到默认值呢Ios 如何在点击MKPinAnnotationView时为注释添加动画?,ios,map,annotations,mapkit,mkpinannotationview,Ios,Map,Annotations,Mapkit,Mkpinannotationview,我在地图视图中有一个自定义pin,我需要在点击时放大pin,然后在按下其他pin时返回默认大小,就像foursquare应用程序一样 这是我用来放大它的代码,但是当我点击另一个引脚时,如何将它返回到默认值呢 - (void)mapView:(MKMapView *)mapView1 didSelectAnnotationView:(MKAnnotationView *)mapView2 { id<MKAnnotation> annotation = mapView2.annota
- (void)mapView:(MKMapView *)mapView1 didSelectAnnotationView:(MKAnnotationView *)mapView2
{
id<MKAnnotation> annotation = mapView2.annotation;
if ([annotation isKindOfClass:[MKUserLocation class]]) {
// this is where you can find the annotation type is whether it is userlocation or not...
}
else
{
float spanX = 0.00725;
float spanY = 0.00725;
MKCoordinateRegion region;
region.center.latitude = annotation.coordinate.latitude;
region.center.longitude = annotation.coordinate.longitude;
region.span.latitudeDelta = spanX;
region.span.longitudeDelta = spanY;
[self.mapView setRegion:region animated:YES];
CGRect frame;
MapAnnotation* ann = annotation;
NSInteger ind = [annotationArr indexOfObject:ann];
frame.origin.x = self.cellScrollBar.frame.size.width * ind;
frame.origin.y = 0;
frame.size = self.cellScrollBar.frame.size;
[self.cellScrollBar scrollRectToVisible:frame animated:YES]; // scroll to the cell of the tapped pin
[UIView animateWithDuration:0.5 animations:^{
mapView2.transform =CGAffineTransformMakeScale(1.3,1.3);
}];
}
}
-(void)地图视图:(MKMapView*)地图视图1未选择注释视图:(MKAnnotationView*)地图视图2
{
id注释=mapView2.0注释;
if([annotation isKindOfClass:[MKUserLocation类]]){
//在这里可以找到注释类型,无论它是否为userlocation。。。
}
其他的
{
浮动范围x=0.00725;
浮子跨距Y=0.00725;
协调区域;
region.center.latitude=annotation.coordinate.latitude;
region.center.longitude=annotation.coordinate.longitude;
region.span.latitudeDelta=spanX;
region.span.longitudeDelta=spanY;
[self.mapView setRegion:区域动画:是];
CGRect帧;
MapAnnotation*ann=注释;
NSInteger ind=[annotationArr indexOfObject:ann];
frame.origin.x=self.cellScrollBar.frame.size.width*ind;
frame.origin.y=0;
frame.size=self.cellScrollBar.frame.size;
[self.cellScrollBar scrollRectToVisible:帧动画:是];//滚动到螺纹销的单元格
[UIView animateWithDuration:0.5动画:^{
mapView2.transform=CGAffineTransformMakeScale(1.3,1.3);
}];
}
}
请您帮助我解决这个问题您是否尝试过使用在取消选择批注时调用的DidDecleAnnotationView委托方法?不知道为什么我以前没有看到这个方法,,是的,我现在试了一下,它还可以工作,但是还有一件事,为了让它恢复到我应该使用的trasformScale是-1.3和-1.3吗?试着将转换设置为
CGAffineTransformity
。谢谢你的帮助