我正在iPhone上開發一個使用LocationManager的位置跟蹤應用程序。以下是我的問題。 如果用戶點擊iphone上的Home按鈕,這意味着應用程序切換到後端,位置管理器的線程是否仍然工作?位置管理員會更新當前位置嗎?以下是示例代碼。LocationManager在IOS的後端工作
CLLocationManager *_locationManager;
- (void)startStandardUpdates {
if (nil == locationManager) {
locationManager = [[CLLocationManager alloc] init];
}
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
// Set a movement threshold for new events.
locationManager.distanceFilter = kCLLocationAccuracyNearestTenMeters;
//Will the thread still work even the application is switched to background?
[locationManager startUpdatingLocation];
CLLocation *currentLocation = locationManager.location;
if (currentLocation) {
PAWAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate.currentLocation = currentLocation;
}
}
'printf' 式和測試自己這一點! – Oliver