- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
出于某种原因,我无法从我的代码中获取城市(地区)的名称。请帮忙!
- (void)viewDidLoad {
[super viewDidLoad];
self.lm = [[CLLocationManager alloc] init];
lm.delegate = self;
lm.desiredAccuracy = kCLLocationAccuracyBest;
lm.distanceFilter = kCLDistanceFilterNone;
[lm startUpdatingLocation];
}
- (void) locationManager:(CLLocationManager *)manager didUpdateToLocation: (CLLocation *) newLocation fromLocation: (CLLocation *)oldLocation {
if (!geocoder) {
geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate];
geocoder.delegate = self;
[geocoder start];
}
NSString *lat = [[NSString alloc] initWithFormat:@"%f", newLocation.coordinate.latitude];
NSString *lng = [[NSString alloc] initWithFormat:@"%f", newLocation.coordinate.longitude];
NSString *acc = [[NSString alloc] initWithFormat:@"%f", newLocation.horizontalAccuracy];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:lat message:lng delegate:self cancelButtonTitle:acc otherButtonTitles: @"button", nil];
[alert show];
[alert release];
[lat, lng, acc release];
}
- (void) reverseGeocoder:(MKReverseGeocoder *)geo didFailWithError:(NSError *)error {
[geocoder release];
geocoder = nil;
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geo didFindPlacemark:(MKPlacemark *)placemark {
**THIS IS WHERE THE ERROR IS OCCURRING** (REQUEST FOR MEMBER 'LOCALITY' IN SOMETHING NOT A STRUCTURE OR UNION)
location = [NSString stringWithFormat:@"%@", placemark.locality];
[geocoder release];
geocoder = nil;
}
最佳答案
我意识到这是一个相对较老的问题,但是......
我遇到了完全相同的问题并求助于使用 addressDictionary 地标属性,例如,
[placemark.addressDictionary objectForKey@"City"]
代替
placemark.subAdministrativeArea
我不明白为什么后者也不起作用。
关于iphone - MKReverseGeocoder 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7304022/
我刚刚看到 MKReverseGeocoder 已被弃用。问题是,如何以最简单的方式更改为 CLGeocoder?抱歉,源代码非常长(我认为您认为它非常简单,但我对此很陌生)。这是我之前得到的...
我有与优步应用程序相同的解决方案。我想定位自己(这很简单)并在屏幕中央放置一些图钉。当我滚动 map 时,红色图钉停留在屏幕中央,文本字段中更新了红色图钉所在的街道名称。 我发现我必须为这个居中的图钉
出于某种原因,我无法从我的代码中获取城市(地区)的名称。请帮忙! - (void)viewDidLoad { [super viewDidLoad]; self.lm
我想问一下关于 MKReverseGeocoder 的内存管理,在 iOS4.3 之前我一直在使用下面的代码,分配 MKReverseGeocoder 然后释放它reverseGeocoder:did
在 MKReverseGeocoder 的文档中,administrativeArea 属性为您提供用户当前所处的状态,并且在示例中提到它返回状态名称或其缩写。我想知道是否有人知道如何获取缩写而不是完
我尝试使用 cllocation 和 mkreversegeocoder 检索城市名称。在我的 viewdidload 方法中,我是 cllocationmanager: self.locManage
我有一个应用程序出现间歇性崩溃。崩溃日志显示了一个堆栈跟踪,这对我来说很难破译,因此希望其他人看到了这一点并能为我指出正确的方向。 基本上,应用程序在启动时执行反向地理编码请求,以在标签中显示用户的位
目前我正在开发一个iPhone应用程序,我必须在其中显示我正在使用Mapkit框架的用户当前的城市和位置。当我构建应用程序时,它工作正常并显示确切的城市详细信息。但是现在当我尝试时再次构建应用程序应用
有没有办法等待地理编码器调用 didFailWithError 或 didFindPlaceMark? 我的问题是我必须调用一个接收坐标并返回保存地址的地标的方法。但是当我调用 [myGeocoder
我正在尝试在两个位置之间绘制路线。为此,我有两个 CLLocation 实例起点,终点。我想将这两个位置转换为两个对应的位置地址。之后我想从谷歌地图网络服务中获取所有路线点。下面的代码也是如此。 -
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭
我正在尝试使用 MKReverseGeocoder 传递通过 CLLocation 类获得的坐标来检测当前用户地址。读书MKReverseGeocoder Class Reference我注意到了 T
我正在尝试为天气功能(全部包含)创建一个单例类,以便我可以在单个分配的对象中更改/更新/调用整个应用程序中的天气数据。 除了一个奇怪的小错误外,我可以正常工作。我在运行 iOS 0){
我正在尝试使用 MKReverseGeoCoder 获取用户当前所在城市的名称,但它有一些我无法识别的错误。以下是详细信息: 它有一些我无法识别的错误 Undefined symbols: ".o
我正在查看直接从 CurrentAddress sample 中的 MapViewController.m 文件提取的这段代码可以在 Apple 的网站上找到: - (void)dealloc {
我正在使用 MKReverseGeocoder 和 locationManager 的 didUpdateToLocation 委托(delegate) 但是我想知道当我在 设备。 我的代码如下:-
从 iOS 4.3 (GM Seed 10M2518) 开始,我在使用 MKReverseGeocoder 时遇到崩溃。 reverseGeocoder:didFailWithError: 被调用时经
我是一名优秀的程序员,十分优秀!