1

任何人都可以讓我知道是否有可能處理像OrientationChanged,Shake,LocationChanged等事件。當我的應用程序在後臺運行?iPhone:捕捉應用程序在後臺運行時的事件

我試過下面的代碼,但只有當我的應用程序在前臺運行時纔會被調用!

- (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); 
} 

謝謝。

回答

相關問題