用到的类 MKMapView
设置MKMapView实例的一些属性,并且指定的伪托就可以进行用户的位置跟踪
这些属性是
_mapView.showsUserLocation = YES; //是否允许进行位置跟踪
[_mapViewsetUserTrackingMode:MKUserTrackingModeFollowWithHeadinganimated:YES];//位置跟踪模式
需要实现的委托是
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
_mapView.centerCoordinate = userLocation.location.coordinate;//实施更新mapView的中心
}
注释:模拟位置的时候可通过Edit Scheme选项进入然后进行设置默认的位置,程序跑起来后可通过设置目标位置进行位置变化的跟踪,目标位置在Simulate location处设置