特にアプリケーションがバックグラウンドにある場合に、位置情報の更新を取得しようとしています。アプリケーションがバックグラウンドに入ると、n 分ごとに位置情報の更新を送信する必要があります。まずフォアグラウンドで試してみましたが、問題なく動作しています。同じコードを applicationDidEnterBackground にコピーしましたが、場所の更新を印刷できません。どこにぶつけられたのかわからないので助けてください。
ビューでDidLoad
- (void)viewDidLoad {
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
[locationManager startUpdatingLocation];
}
と
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
int degrees = newLocation.coordinate.latitude;
double decimal = fabs(newLocation.coordinate.latitude - degrees);
int minutes = decimal * 60;
double seconds = decimal * 3600 - minutes * 60;
NSString *lat = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
degrees, minutes, seconds];
latLabel.text = lat;
degrees = newLocation.coordinate.longitude;
decimal = fabs(newLocation.coordinate.longitude - degrees);
minutes = decimal * 60;
seconds = decimal * 3600 - minutes * 60;
NSString *longt = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
degrees, minutes, seconds];
longLabel.text = longt;
}
これらのメソッドを AppDelegate に貼り付けてみました。機能していません:(。助けてください