当我的应用程序在后台运行时,谁能告诉我是否可以处理诸如 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);
}
谢谢。