3

您好,我是 ios 新手,使用来自服务器的 lat 和 long 在地图视图上显示注释。我有一个视图控制器,我在其中添加地图并显示纬度和经度的位置。但是我的问题是,每当我添加注释图时,每次我想要捏图视图时都不会关注它的注释,然后地图将进入注释我不知道为什么会这样?

zoomLocation.latitude = latmpa.doubleValue;
zoomLocation.longitude = logmpa.doubleValue;
annotationPoint = [[MKPointAnnotation alloc] init];
annotationPoint.coordinate = zoomLocation;
annotationPoint.title = @"masjid....";
[mapView selectAnnotation:annotationPoint animated:YES];

[mapView addAnnotation:annotationPoint];

here is my code adding in viewwillappera  
4

2 回答 2

3

您需要使用以下代码使地图居中。

mapView.centerCoordinate = annotationPoint.coordinate;
于 2013-10-27T07:01:15.157 回答
2

Milan 的解决方案无需动画即可满足您的需求。如果你想用动画做到这一点,你应该使用:

    [mapView setCenterCoordinate:location animated:YES];
于 2014-09-17T06:16:29.013 回答