2016-09-06 91 views
0

我有一个应用程序,允许用户在一个视图上选择大学,并在他们选择后,该视图解散并显示地图。目前,我使用下面的代码,但它动画所有注释。我希望现有的注释不会动画,只有当视图被解散时才会对新选择的大学生成动画。如何动画刚删除的注释?

func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { 
    let reuseID = "pin" 

    var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseID) as? MKPinAnnotationView 

    if pinView == nil { 
     pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseID) 
     pinView?.canShowCallout = true 
     pinView?.rightCalloutAccessoryView = UIButton(type: .DetailDisclosure) 
     pinView?.animatesDrop = true 
    } else { 
     pinView?.annotation = annotation 
     pinView?.animatesDrop = true 
    } 
    return pinView 
} 

回答

0

您可以创建一个自定义的注释和一个布尔值添加到它来检查,如果它之前已经或不添加。

class CustomPointAnnotation: MKPointAnnotation { 
    var name: String! 
    var exists: Bool! 
} 

然后用CustomPointAnnotation当您添加注释和检查existstrue那么你鸵鸟政策有生如果false然后进行动画处理。