Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 用户位置每10秒更新到wifi_Iphone_Gps_Cllocationmanager - Fatal编程技术网

Iphone 用户位置每10秒更新到wifi

Iphone 用户位置每10秒更新到wifi,iphone,gps,cllocationmanager,Iphone,Gps,Cllocationmanager,我试图从代码开始每隔10秒更新一次userlocation。但当我从wifi移动到3G时,我面临一个问题。每个备用请求都来自我的wifi所在的位置。可以做些什么 这是我的密码 NSN编号*n1; NSN编号*n2 if([ud boolForKey:@"applicationActive"]) { n1 = [NSNumber numberWithDouble:[map.userLocation coordinate].latitude]; n2

我试图从代码开始每隔10秒更新一次userlocation。但当我从wifi移动到3G时,我面临一个问题。每个备用请求都来自我的wifi所在的位置。可以做些什么

这是我的密码

NSN编号*n1; NSN编号*n2

    if([ud boolForKey:@"applicationActive"])
    {

        n1 = [NSNumber numberWithDouble:[map.userLocation coordinate].latitude];
        n2 = [NSNumber numberWithDouble:[map.userLocation coordinate].longitude];
    }
    else
    {
        CLLocationManager *locationManager = [[CLLocationManager alloc] init];
        locationManager.delegate = self;
        [locationManager startUpdatingLocation];
        n1 = [NSNumber numberWithDouble:locationManager.location.coordinate.latitude];
        n2 = [NSNumber numberWithDouble:locationManager.location.coordinate.longitude];
        [locationManager stopUpdatingLocation];
    }


    [dict setObject:[ud objectForKey:@"CurrentDriverID"] forKey:@"DriverId"];
    [dict setObject:[n1 stringValue] forKey:@"Latitude"];
    [dict setObject:[n2 stringValue] forKey:@"Longitude"];

    [requestG SaveDriverlocationWS:dict delegate:self];

注意:发生这种情况时,应用程序将保持在前台。SaveDriverlocationWS方法将当前位置保存到服务器

您似乎没有为您的位置管理器设置准确度级别-我会尝试一下,看看情况是否有所改善。从您的代码来看,您可能正在为驱动程序编写一个应用程序,在这种情况下,您可能希望使用
kCallocationAccuracybestforNavigation
精度级别(如果需要,您应该使用另一个更合适的级别,因为
BestForNavigation
过滤器耗电量很大,专为手机位于汽车停靠站并通电的情况而设计).

以我的理解。使用Wifi或3G是系统级设置。CLLocationManager使用当前系统的网络来获取设备的位置,而程序员无处在3G/Wifi之间切换网络。

即使我离开始使用的Wifi网络几英里,也会发生这种情况。不确定是否存在准确性问题?是的,我的问题是t当我离开wifi,手机自动切换到3G时,手机会在当前位置和我开始使用的wifi位置之间切换。知道应该怎么做吗?谢谢你的意思是最后一个wifi位置和新的3G位置之间存在显著差异?是的。我从wif启动应用程序我知道它的位置。但当我从wifi移动到3g时,问题开始了……iOS 6,你一定会喜欢它的新功能。