Roh*_*yap 5 cllocationmanager ios6
我想实现一个功能,我使用GPS进行更新,当用户不移动时,我希望暂停GPS更新.根据" 与位置服务保持同步 "视频,我这样做了:
//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];
Run Code Online (Sandbox Code Playgroud)
代表:
- (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];
}
Run Code Online (Sandbox Code Playgroud)
我没有得到所需的行为,当设备空闲时,代理人"didPause .."和"didResume ..."甚至没有被调用.
理想情况下,GPS更新必须停止和恢复,具体取决于设备的状态和CLActivityType,但不是这里的情况.
任何人都可以帮助我,我做错了什么?
提前致谢.
| 归档时间: |
|
| 查看次数: |
2698 次 |
| 最近记录: |