我试图从我的代码中每隔10秒更新用户位置。但是当我从wifi移动到3G时,我面临一个问题。每一个替代的请求都来自我的wifi所在的位置。可以做什么?用户位置每10秒更新一次无线网络
这是我的代码
NSNumber * n1; NSNumber * 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方法将当前位置保存到服务器上
http://www.macrumors.com/2012/08/09/ios-6-beta-adds-wi-fi-plus-cellular-option-to-increase-data-reliability/。 iOS 6,你必须爱上它的新功能。 – 2012-08-14 02:45:39