我想實現我使用GPS的loaction更新,並在用戶不動,我想被暫停的GPS更新一個功能不能正常工作。 按了「停留在軌道與位置服務」的視頻,我這樣做:pausesLocationUpdatesAutomatically在iOS 6中如預期
//Configure Location Manager
self.theLocationManager = [[CLLocationManager alloc]init];
[self.theLocationManager setDelegate:self];
[self.theLocationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[self.theLocationManager setActivityType:CLActivityTypeFitness];
NSLog(@"Activity Type Set: CLActivityTypeFitness");
[self.theLocationManager setPausesLocationUpdatesAutomatically:YES];
[self.theLocationManager startUpdatingLocation];
代表:
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations
{
NSLog(@"Started location Updates");
}
- (void)locationManagerDidPauseLocationUpdates:(CLLocationManager *)manager
{
NSLog(@"Pausing location Updates");
}
- (void)locationManagerDidResumeLocationUpdates:(CLLocationManager *)manager
{
NSLog(@"Resuming location Updates");
UIAlertView *pop = [[UIAlertView alloc]initWithTitle:@"Info" message:@"Location Updates resumed" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[pop show];
[pop release];
}
我沒有得到期望的行爲,並代表「didPause .. 「和」didResume ...「甚至在設備閒置時都不會被調用。
理想的GPS更新必須停止並恢復取決於設備和CLActivityType,但它不是這裏的情況的狀態。
誰能幫助我,我究竟做錯了什麼?
在此先感謝。如果你讓設備在同一地點約15分鐘應該發生
源嗎? – androniennn
是的請源? – loki
@androniennn我曾多次嘗試。根據我的經驗,16-17分鐘就是這樣。顯然蘋果不希望開發人員知道這些數字。 – Honey