本文介绍了默认显示当前位置标注的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个当前位置标注(蓝点)显示mapkit。注释显示录音蓝点后,
我怎么能在默认情况下注释的表现?当我开始的看法?白衣出攻针。

   - (空)的MapView:(*的MKMapView)MV didAddAnnotationViews:(NSArray的*)的意见{
    对于(MKAnnotationView *在意见annotationView){
        如果(annotationView.annotation == mv.userLocation){            self.mapView.userLocation.title = @当前;
            self.mapView.userLocation.subtitle = @位置;            MKCoordinateRegion区域;
            MKCoordinateSpan跨度;            span.latitudeDelta = 0.002;
            span.longitudeDelta = 0.002;            CLLocationCoordinate2D位置= mv.userLocation.coordinate;            region.span =跨度;
            region.center =位置;            [MV setRegion:地区动画:是];
            [MV regionThatFits:区];        }
    }}


解决方案

在这种情况下,selectAnnotation应该工作,不是吗?只是performSelector一个小的时间了。

....相同code和以前一样,但插入此:

  ID =注释annotationView.annotation;
            [自performSelector:@选择(selectUserLocation :) withObject:注释afterDelay:0.1F];
        }
    }
} - (无效)selectUserLocation:(ID)注释{
    [self.mapView selectAnnotation:注释动画:是];
}

I have an current location annotation (blue dot) showing in mapkit. Annotation shows after taping the blue dot,how can I have the annotation showing by default?, when I start the view? whit out tapping the pin.

 - (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views {
    for(MKAnnotationView *annotationView in views) {
        if(annotationView.annotation == mv.userLocation) {

            self.mapView.userLocation.title= @"Current";
            self.mapView.userLocation.subtitle= @"Location";

            MKCoordinateRegion region;
            MKCoordinateSpan span;

            span.latitudeDelta=0.002;
            span.longitudeDelta=0.002;

            CLLocationCoordinate2D location=mv.userLocation.coordinate;

            region.span=span;
            region.center=location;

            [mv setRegion:region animated:YES];
            [mv regionThatFits:region];

        }
    }

}
解决方案

In that case, selectAnnotation should work, wouldn't it? Just performSelector after a small time.

.... same code as before but insert this:

            id annotation = annotationView.annotation;
            [self performSelector:@selector(selectUserLocation:) withObject:annotation afterDelay:0.1f];
        }
    }
}

- (void)selectUserLocation:(id)annotation{
    [self.mapView selectAnnotation:annotation animated:YES];
}

这篇关于默认显示当前位置标注的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 04:35