2012-07-17 58 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