2013-04-08 3 views
0

В моем mapview у меня в настоящее время есть bool animatesDrop для аннотаций, установленных как NO. Это связано с тем, что когда аннотации mapView отображаются на экране viewWillAppear, я не делаю их анимированными. Тем не менее, у меня также есть кнопка обновления, используемая для повторной привязки аннотаций и хотелось бы, чтобы они были анимированы (отбрасываются), когда это было нажато. Есть ли способ сделать это? Благодарю.iOS mapView animatesDrop

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { 

    if ([annotation isKindOfClass:[MKUserLocation class]]) { 

     return nil; 
    } 

    MyPin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"current"]; 

    UIButton *calloutButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 

    UIButton *directionsButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
    directionsButton.frame = CGRectMake(0, 0, 23, 23); 
    [directionsButton setBackgroundImage:[UIImage imageNamed:@"directions.png"] forState:UIControlStateNormal]; 

    MyPin.leftCalloutAccessoryView = directionsButton; 
    MyPin.rightCalloutAccessoryView = calloutButton; 
    MyPin.draggable = NO; 
    MyPin.highlighted = NO; 
    MyPin.animatesDrop= YES; 
    MyPin.canShowCallout = YES; 

    return MyPin; 
} 

ответ

2

подход «Hard Ball» будет установить логическое свойство, значение ЛОЖЬ в viewWillAppear, но значение ИСТИНА в действии вашей кнопки. установите MyPin.animatesDrop для свойства в viewForAnnotation. Не знаю ни одного «элегантного» решения.

0

Удалить все аннотации, используя код

[self.mapView removeAnnotations:self.usersAnnotationArray]; 

И аннотацию еще раз MapView, проверить нажатие кнопки с помощью BOOL переменной и установите

MyPin.animatesDrop= YES; 

в методе delagate

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation 
{ 
...... 
...... 
...... 
if(_IsButtonClikced) 
{ 
    MyPin.animatesDrop= YES; 

} 
else 
{ 
    MyPin.animatesDrop= NO; 

} 

................ 
....... 
..... 
} 
Смежные вопросы