【问题标题】:iOS mapView animatesDropiOS mapView 动画Drop
【发布时间】:2013-04-08 23:32:31
【问题描述】:

在我的地图视图中,我目前将注释的 bool animatesDrop 设置为 NO。这是因为在 viewWillAppear 期间绘制 mapView 注释时,我不会在它们动画时。但是,我还有一个刷新按钮,用于重新绘制注释,并希望它们在按下时动画(删除)。有没有办法做到这一点?谢谢。

-(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;
}

【问题讨论】:

    标签: ios xcode animation annotations mkmapview


    【解决方案1】:

    “硬球”方法是建立一个布尔属性,在 viewWillAppear 中设置为 false,但在按钮的操作中设置为 true。将 MyPin.animatesDrop 设置为 viewForAnnotation 中的属性。不知道任何“优雅”的解决方案。

    【讨论】:

      【解决方案2】:

      使用代码删除所有注释

      [self.mapView removeAnnotations:self.usersAnnotationArray];
      

      再次注释到 mapview ,检查按钮单击使用BOOL 变量并设置

      MyPin.animatesDrop= YES;
      

      在委托方法中

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-11-21
        • 2012-03-15
        相关资源
        最近更新 更多