地图视图总是在我的位置中心地图 [英] Map View always center map on my location

查看:100
本文介绍了地图视图总是在我的位置中心地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户按下按钮时,我使用以下代码获取我的位置

I use the following code to get my location when a user presses a button

 [mapview setShowsUserLocation:YES];

然后将地图居中到te用户的位置

and then the follwoing to center the map to te user's location

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation      
{
   [mapView setCenterCoordinate:mapView.userLocation.location.coordinate animated:YES];
} 

我的问题是如何防止地图始终以我的位置为中心?我想允许用户平移地图。

My question is how to prevent the map from always centering on my location? I want to allow the user to pan the map.

推荐答案

我认为它是用iOS5进行的,你现在可以放弃代表了东西,只需设置MKMapView的userTrackingMode。将它设置为MKUserTrackingModeFollow以使make与用户一起移动,然后当它们开始平移地图时它将自动关闭跟踪模式,然后您只需要提供一个按钮将其重新打开。

I think it came in with iOS5, you can now drop the delegate stuff and just set the userTrackingMode of the MKMapView. Set it to MKUserTrackingModeFollow to make the make move along with the user and then when they start panning the map around it'll turn off the tracking mode automatically, you then just need to provide a button to turn it back on.

这篇关于地图视图总是在我的位置中心地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆