Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.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
Ios 没有internet,无法调用Cllocationmanager Didupdatelocation委托_Ios_Objective C_Cllocationmanager - Fatal编程技术网

Ios 没有internet,无法调用Cllocationmanager Didupdatelocation委托

Ios 没有internet,无法调用Cllocationmanager Didupdatelocation委托,ios,objective-c,cllocationmanager,Ios,Objective C,Cllocationmanager,我目前正在开发一个基于位置的ios应用程序。我正在使用didupdatelocationdelegate方法显示用户的当前位置。当我将设备连接到internet时,它工作正常。但是当我断开互联网时,它的行为会很奇怪,didupdatelocation不会被进一步调用。请给出一个解决方案。 已编辑,包含代码详细信息 - (void)viewDidLoad { [super viewDidLoad]; locationManager = [[CLLocationManager all

我目前正在开发一个基于位置的ios应用程序。我正在使用
didupdatelocation
delegate方法显示用户的当前位置。当我将设备连接到internet时,它工作正常。但是当我断开互联网时,它的行为会很奇怪,
didupdatelocation
不会被进一步调用。请给出一个解决方案。 已编辑,包含代码详细信息

- (void)viewDidLoad
{
    [super viewDidLoad];
    locationManager = [[CLLocationManager alloc]init]; // initializing locationManager
    locationManager.delegate = self; // we set the delegate of locationManager to self. 
    locationManager.desiredAccuracy = kCLLocationAccuracyBest; // setting the accuracy

    [locationManager startUpdatingLocation];  //requesting location updates
}

-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
    UIAlertView *errorAlert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"There was an error retrieving your location" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
    [errorAlert show];
    NSLog(@"Error: %@",error.description);
}
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
    CLLocation *crnLoc = [locations lastObject];
    latitude.text = [NSString stringWithFormat:@"%.8f",crnLoc.coordinate.latitude];
    longitude.text = [NSString stringWithFormat:@"%.8f",crnLoc.coordinate.longitude];
    altitude.text = [NSString stringWithFormat:@"%.0f m",crnLoc.altitude];
    speed.text = [NSString stringWithFormat:@"%.1f m/s", crnLoc.speed];
}

你可以使用iPhone的基本GPS,它也可以在没有互联网的情况下工作。要访问它,您需要使用CoreLocation框架

您可以参考以下内容:使用GPS数据


如果需要任何其他帮助,请告诉我。

@ANSHAD根据您的评论,如果您使用的是没有GPS的旧iPad,您获取位置数据的唯一方法是使用WiFi,因此如果您关闭WiFi,您将无法获得位置更新。如果您想要不带WiFi的GPS,您可以购买不带internet连接的外部GPS模块

,因为location manager无法访问您当前的位置。试一试internet@SarathiOS:我的应用程序需要脱机导航(无internet):(它将显示您的当前位置,但在没有internet的情况下,您无法在地图视图中将其映射。@Sarath iOS:有时它工作正常,但有时不会,映射不是问题,因为我不使用mapview,我只想调用这些委托方法。我有一个具有类似要求的应用程序。调用了CLLocationManager委托方法。演示我是如何使用这些方法的。)安装CLLocationManager和一些相关代码。是否检查CLLocationManager的错误?抱歉,我的应用程序仅适用于ipad设备:(是的,GPS芯片在所有的ios设备中都可以使用。所以在ipad中也可以使用。请参考:
https://github.com/shawngrimes/Location-and-Map-Sample
实际上,单独的gps模块仅适用于某些ios设备,如iphone、3g iPad等。。