Iphone GPS无法提供准确的纬度和经度

Iphone GPS无法提供准确的纬度和经度,iphone,ios,cllocationmanager,Iphone,Ios,Cllocationmanager,你好,朋友,我看过很多关于gps精度问题的帖子,但它不是一直在工作 -(void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSString *latstr = [NSString stringWithFormat:@"%f", newLocation.coord

你好,朋友,我看过很多关于gps精度问题的帖子,但它不是一直在工作

-(void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{

    NSString  *latstr = [NSString stringWithFormat:@"%f", newLocation.coordinate.latitude];
    NSString  *longstring=[NSStringstringWithFormat:@"%f",newLocation.coordinate.longitude];

     if (abs(howRecent)>5.0)
     {
         [self.locationManager startUpdatingLocation];
         return;
      }
    if(abs(newLocation.horizontalAccuracy)<0.0f)
    {
        [self.locationManager startUpdatingLocation];
        return;
    }
    if(newLocation.horizontalAccuracy>65.0f)
    {
        [self.locationManager startUpdatingLocation];
        return;
    }
    self.latstring = [latstr copy];
    self.longstr = [longstring copy];

    if((updateLocationFirst||loadFirstView))
    {    
        [[NSUserDefaults standardUserDefaults]setObject:latstring forKey:@"Latitude"];
        [[NSUserDefaults standardUserDefaults]setObject:longstr forKey:@"Longitude"];
        [self displayParticularDaySpecial];
        loadFirstView=FALSE;
        updateLocationFirst=FALSE;
        [self.locationManager stopUpdatingLocation];
    }
}
-(void)locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*)oldLocation
{
NSString*latstr=[NSString stringWithFormat:@“%f”,newLocation.coordinate.latitude];
NSString*longstring=[NSSTRINGWITHFORMAT:@“%f”,newLocation.coordinate.longitude];
如果(abs(最近更新)>5.0)
{
[self.locationManager startUpdatingLocation];
返回;
}
if(abs(新定位水平精度)65.0f)
{
[self.locationManager startUpdatingLocation];
返回;
}
self.latstring=[latstr copy];
self.longstr=[longstring copy];
如果((updateLocationFirst | | loadFirstView))
{    
[[NSUserDefaults standardUserDefaults]setObject:latstring-forKey:@“纬度”];
[[NSUserDefaults standardUserDefaults]setObject:longstr-forKey:@“经度”];
[自显示特殊日期];
loadFirstView=FALSE;
updateLocationFirst=FALSE;
[self.locationManager停止更新位置];
}
}

这里的问题是,如果我正在降低精度值,那么我会将某些地址的纬度和经度发送到google api。加载该值需要花费大量时间,并且当您到达与0.6英里差的目的地相关的目的地时,该值会出现问题。

是否在您的应用程序中设置了DesiredLocationAccuranceCLLocationManager?默认情况下,范围比较宽

获取一个非常精确的值需要一些时间。

您应该参考,它提供了非常好的编程示例来确定您的位置

正如您将在该文档的演示中所看到的,当您需要时,您通常会告诉它您需要的准确性。一旦启动location manager,就不必再次启动它(就像您在代码示例中所做的那样)。
didUpdateLocations
方法将被一次又一次地调用,并且精度越来越高,这一切都是靠它自己实现的。您不需要再次启动位置管理器。。。它一直运行,直到你关掉它。根据定义,如果您处于
didUpdateLocations
,则表示它已处于启用状态

我还注意到你用的是旧的。如果你在为iOS 6编程,你真的想使用,这是该方法的当前版本

最后,你提到要花很长时间才能找到你的位置。那是很有可能的。事实上,在某些地区,你永远不会离得很近(或任何地点)。你的应用程序应该假设准确的位置需要一段时间,如果你从来没有得到一个真正准确的位置,你应该优雅地处理,这是很有可能的。

顺便说一下
abs(newLocation.horizontalAccurance)