1

アプリがバックグラウンドで実行されているときに、OrientationChanged、Shake、LocationChanged などのイベントを処理できるかどうかを教えてください。

次のコードを試してみましたが、アプリがフォアグラウンドで実行されている場合にのみ呼び出されます!

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
//if the time interval returned from core location is more than two minutes we ignore it because it might be from an old session
if ( abs([newLocation.timestamp timeIntervalSinceDate: [NSDate date]]) < 120) {     
    self.currentLocation = newLocation;
}
NSLog(@"lat: %f long:%f",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude);
}

ありがとう。

4

1 に答える 1

2

http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html

キーUIRequiredDeviceCapabilitiesの下のinfo.plistファイルに位置情報サービスを含める必要があります

その後、アプリはバックグラウンドで位置情報の更新を受け取ります。ただし、これにより、バッテリーの消耗が速くなります。ユーザーがあまり知らなくても、可能であれば、重要な場所にのみ登録する必要があります。

向きを変更した更新は、バックグラウンドではできません。シェイクかもしれません..わかりません

于 2012-01-19T13:53:06.807 に答える