2012-07-17 80 views
0

我有这样的代码删除,并在我的地图上添加新的引脚:IOS:MKPinAnnotationView动画降不工作

- (IBAction)setLocation:(id)sender{ 

    NSMutableArray *toRemove = [NSMutableArray arrayWithCapacity:1]; 
    for (id annotation in map.annotations) 
     if (annotation != map.userLocation) 
      [toRemove addObject:annotation]; 
    [map removeAnnotations:toRemove]; 


    MKPointAnnotation *annotationPoint = [[[MKPointAnnotation alloc] init]autorelease]; 
    annotationPoint.coordinate = map.userLocation.coordinate; 
    annotationPoint.title = @"Position"; 
    [map addAnnotation:annotationPoint]; 

    MKPinAnnotationView *pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotationPoint reuseIdentifier:@"Pin"] autorelease]; 
    pinView.pinColor = MKPinAnnotationColorRed; 
    pinView.canShowCallout = YES; 
    //pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
    pinView.animatesDrop = TRUE; 


} 

,但我把我的脚就不会做动画,但我设置animatesDrop =真的,为什么?

回答

0

我认为这可能有帮助。我相信你可以尝试使用MKMapViewDelegate(苹果文件,检查MapCallouts示例项目)方法:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation 
{ 
    MKPinAnnotationView* customPinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil] autorelease]; 

// alter properties of the customPinView 

    return customPinView; // if you return nil... then the MKPinAnnotation default will be dropped. 
} 

确保添加<MKMapViewDelegate>协议在头

1

看来你并没有将pinView添加到地图中。

+0

没有,当我把这个IBAction为pinView出现.. .so你有什么解决方案? – CrazyDev 2012-07-17 23:18:10