0
這個問題一直困擾着我一段時間:我的地圖,當我在我的iOS設備上運行時,無論何時滾動到我的iOS設備,都開始回到用戶位置看看我最近放棄的另一個針腳。奇怪的是,最近纔開始這樣做。iOS 8 - 地圖不斷重新回到用戶位置
這裏是我的代碼爲:
- (void)viewDidLoad
{
[super viewDidLoad];
self.searchBar.delegate = self;
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
if ([self.locationManager respondsToSelector:@selector
(requestWhenInUseAuthorization)]) {
[self.locationManager requestWhenInUseAuthorization];
mapView.showsUserLocation = YES;
}
[self.locationManager startUpdatingLocation];
}
#pragma mark cllocation delegate methods
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:
(NSArray *)locations
{
NSLog(@"location info object=%@",[locations lastObject]);
[self.locationManager stopUpdatingLocation];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Location Success"
message:@"Location
received" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
我如何能處理用戶的位置問題的任何想法?
Matt的回答是正確的,MapView正在跟蹤用戶的位置。缺少的部分是如何阻止這一點。爲了阻止它跟蹤用戶的位置,當你告訴你的locationManager stopUpdatingLocation時,嘗試設置showsUserLocation爲NO。試試看看會發生什麼。 – 2014-11-24 19:40:16
這個答案正確嗎? 'showsUserLocation'只是控制是否顯示當前位置註釋。如果'userTrackingMode'設置爲'MKUserTrackingModeNone',那麼地圖不應該放大到用戶 – Paulw11 2014-11-24 20:28:45
@ Paulw11您是否真的讀過我的回答?這就是我所說的:「通常,你會調整MKUserTrackingMode。」問題是用戶跟蹤模式是_not_'MKUserTrackingModeNone'。它是'MKUserTrackingModeFollow'。因此,它隨之而來。 – matt 2014-11-24 21:34:42