为MKPointAnnotation设置新坐标时,引脚消失

时间:2014-03-22 16:20:42

标签: ios objective-c mkpointannotation

当我尝试像这样移动我的MKPointAnnoatation时:

[UIView animateWithDuration:0.5 animations:^{
            [user setCoordinate:coordinate];

图钉在地图上消失:(是否有不同的解决方案来移动MKPointAnnotion?

编辑更多代码:

CLLocationCoordinate2D *plotLocation = malloc(sizeof(CLLocationCoordinate2D) *
                                              _trak.trakTagRelationship.count);

    int i=0;
    for (TrakTag* tag in _trak.trakTagRelationship)
    {

        CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(tag.trakTagX.doubleValue,
                                                                           tag.trakTagY.doubleValue);
        plotLocation[i] = coordinate;


        i++;
    }

    TrakTag* dummy = [[_trak.trakTagRelationship allObjects]lastObject];
    CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(dummy.trakTagX.doubleValue,
                                        dummy.trakTagY.doubleValue);

    if (user != NULL)
    {
        [UIView animateWithDuration:0.5 animations:^{
            [user setCoordinate:coordinate];

            NSLog(@"Annotaions:%@",user);

        }];
    }
    else
    {
        user = [[MKPointAnnotation alloc]init];
        [user setCoordinate:coordinate];
        [mapView addAnnotation:user];
    }


    line = [MKPolyline polylineWithCoordinates:plotLocation count:_trak.trakTagRelationship.count];
    [mapView addOverlay:line];

0 个答案:

没有答案