我查了大约3页关于这是如何工作的。但是,我确实需要一些帮助,因为我得到了kCLError = 15。
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self]
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager startUpdatingLocation];
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation *currentLocation = [locations lastObject];
NSLog(@"%@",[locations lastObject];
NSLog(@"%d",[CLLocationManager deferredLocationUpdatesAvailable]);
[locationManager allowDeferredLocationUpdatesUntilTraveled:CLLocationDistanceMax timeout:CLTimeIntervalMax];在这之后我有我的错误代码
-(void)locationManager:(CLLocationManager *)manager didFinishDeferredUpdatesWithError:(NSError *)error
{
NSString *stringError = [NSString stringWithFormat:@"error: %@",[error description]];
_whatMonitor.text = stringError;
}所以,任何能帮我的人我都会非常感激的。我也有一个位置数组的计数,但这从1。据我了解,在关闭应用程序到主屏幕并锁定设备后,deferredUpdates应该会启动。我已经查过了位置计数,它仍然是1。我期望它会比这个更大。
我不认为自己在这方面很擅长,所以如果我犯了一个粗心的错误,请告诉我。我没有复制和粘贴,所以可能有一些小排版。提前谢谢。
我正在iPhone 5上运行iPhone 6.0。
发布于 2013-08-07 00:26:03
对于重要的更改服务和延迟的位置更新,您必须移动系统以记录更新。您已经指定了CLLocationDistanceMax,这是一个很高的距离值。您可以指定较低的距离以获得更频繁的更改,例如,您可以指定每100米的变化,以触发更新,如下所示:
[locationManager allowDeferredLocationUpdatesUntilTraveled:CLLocation(100) timeout:CLTimeIntervalMax];参考资料:Class/CLLocationManager/CLLocationManager.html
https://stackoverflow.com/questions/18092047
复制相似问题