Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.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中协调的邮政编码_Ios_Objective C_Geocoding - Fatal编程技术网

要在iOS中协调的邮政编码

要在iOS中协调的邮政编码,ios,objective-c,geocoding,Ios,Objective C,Geocoding,我尝试在iOS中使用objective-c从邮政编码中获取坐标,但在我自己的iPhone上,它总是返回中国郑州的固定坐标(我猜它是富士康的工厂,[34.153348113.488374])。但它在模拟器上运行良好 CLGeocoder *geoCoder = [[CLGeocoder alloc] init]; [geoCoder geocodeAddressString:zipcodefield.text completionHandler:^(NSArray *placemarks, NSE

我尝试在iOS中使用objective-c从邮政编码中获取坐标,但在我自己的iPhone上,它总是返回中国郑州的固定坐标(我猜它是富士康的工厂,[34.153348113.488374])。但它在模拟器上运行良好

CLGeocoder *geoCoder = [[CLGeocoder alloc] init];
[geoCoder geocodeAddressString:zipcodefield.text completionHandler:^(NSArray *placemarks, NSError *error) {
    CLPlacemark *placemark = [placemarks objectAtIndex:0];
    CLLocation *location = placemark.location;
    CLLocationCoordinate2D coordinate = location.coordinate;
    NSLog(@"%f", coordinate.latitude);
    NSLog(@"%f", coordinate.longitude);
}];

你们知道为什么吗?谢谢。

您的苹果设备可能已关闭位置服务。@vaibhav抱歉,我不这么认为。我打开了它,这个函数只是将文本转换成坐标。
zipcodefield
只是一个zipcode吗?听起来您需要尝试使用实际地址,而不是
geocodeAddressString
(基于文档)的zipcode。可能您的apple设备中的位置服务已关闭。@vaibhav抱歉,我不这么认为。我打开了它,这个函数只是将文本转换成坐标。
zipcodefield
只是一个zipcode吗?听起来您需要尝试使用实际地址,而不是
geocodeAddressString
(基于文档)的zipcode。