使用以下代码,可以设置一个按钮以在导航栏中切换 setUserTrackingMode。
// set MKUserTrackingBarButton
// source: http://stackoverflow.com/questions/9876157/is-the-current-location-compass- heading-button-available-in-the-ios-sdk
MKUserTrackingBarButtonItem *buttonItem = [[MKUserTrackingBarButtonItem alloc] initWithMapView:self.mapView];
self.navigationItem.rightBarButtonItem = buttonItem;
// set tracking mode
[self.mapView setShowsUserLocation:YES];
[self.mapView setUserTrackingMode:MKUserTrackingModeFollowWithHeading animated:YES];
如何做到这一点(地图内的按钮左下角) Apple 在地图中这样做?(对不起,我不允许张贴图片来澄清它)