iOS 6地图-不设置PIN动画 [英] iOS 6 maps- not animating PIN drop

查看:66
本文介绍了iOS 6地图-不设置PIN动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义的MKAnnotation类,该类一直有效-直到iOS 6发布.从那时起,我的图钉就添加到了苹果地图上,但是现在没有放动画了!这是它的设置方式,还是我的工作方式存在问题.我设置了一个1秒钟的延迟,直到调用将注释添加到地图的方法为止,这样我就可以看到放置动画是否实际上是在视图出现之前发生的-仍然,这些销钉不知不觉地出现了而没有放置.这是我正在使用的代码:

I have created a custom MKAnnotation class and it has been working - until iOS 6 came out. Since then my pins get added to the apple map but now without a drop animation! Is this how it is set or there maybe an an issue with the way I'm doing things. I have set a delay of 1 sec until the method that adds the annotations to the map is called, so I can see if the drop animations are actually occurring before the view appears - still, the pins just appear out of nowhere without dropping. Here's the code I'm using:

-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(Annotation*)annotation
{
    NSLog(@"the annotation ID is: %@", annotation.ID);
    MKPinAnnotationView *MyPin=[[MKPinAnnotationView alloc] initWithAnnotation:annotation   reuseIdentifier:@"current"];

    UIButton *goToObjectButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

    [goToObjectButton addTarget:self action:@selector(goToObjectClick:)  forControlEvents:UIControlEventTouchUpInside];


    MyPin.pinColor = MKPinAnnotationColorRed;
    MyPin.rightCalloutAccessoryView = goToObjectButton;
    MyPin.draggable = NO;
    MyPin.highlighted = YES;
    MyPin.animatesDrop=YES;
    MyPin.canShowCallout = YES;

    return MyPin;
}

推荐答案

看来,在iOS 6中使用新的Apple MapKit时,将注释添加到MKMapView的顺序有所改变.

It appears that with the new Apple MapKit in iOS 6, the sequence of when annotations are added onto a MKMapView has changed a bit.

(对于我自己,我曾经添加注释,然后在iOS 6之前和之前设置地图视图的委托,直到运行周期的后期才出现注释,但现在它们尝试添加立即.)

(In my own case, I used to add annotations, then set the delegate of the map view immediately after, and before iOS 6, the annotations didn't appear until later in the run cycle, but now they try to add immediately.)

因此,这可能是一个问题,要么是在连接代表之前添加了批注,要么是您添加批注的时间太早而又看不到动画.有关何时创建MKMapView(假设您是在代码中而不是.xib中创建)以及何时添加注释的更多代码示例,可能有助于弄清问题所在.

So, it may be an issue that either the annotations are being added before the delegate is hooked up, or that you're adding the annotations too early and just not seeing the animation. More code samples regarding when the MKMapView is being created (assuming you're doing it in code, and not in a .xib) and when you're adding your annotations might help clarify what's wrong.

这篇关于iOS 6地图-不设置PIN动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆