iPhone SDK MKPlacemark
我需要 MapKit 框架方面的帮助。我是 iPhone 开发新手。 我有一个 webview,它从带有 3 个参数的 url 加载,如下所示:
在视图控制器的 viewDidLoad 方法中:
NSString *hoUrlString = [NSString stringWithFormat:@"http://fastenergy.clavis-solutions.de/?iwidth=%@&iheight=%@&zipcode=%@", hString, wString, zipcode];
我无法获取邮政编码。我在 url 之前调用此方法:
locationController = [[HoCLController alloc] init];
locationController.delegate = self;
[locationController.locationManager startUpdatingLocation];
在 HoCLController.m 的这个方法中
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
,我调用
MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:coord];
[geocoder setDelegate:self];
[geocoder start];
然后我有这 2 个方法
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {
NSLog(@"The geocoder has returned: %@", placemark.postalCode);
}
-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error {
NSLog(@"Error: %@", [error description]);
}
问题是,如何获取 url 中的邮政编码?
谢谢你并请帮忙。
I need help with the MapKit framework. I am new to iPhone development.
I have a webview that loads from a url with 3 params like this:
in viewDidLoad method from the view controller:
NSString *hoUrlString = [NSString stringWithFormat:@"http://fastenergy.clavis-solutions.de/?iwidth=%@&iheight=%@&zipcode=%@", hString, wString, zipcode];
I can't get the zipcode. I am calling this before the url:
locationController = [[HoCLController alloc] init];
locationController.delegate = self;
[locationController.locationManager startUpdatingLocation];
and in this method from HoCLController.m
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
, I call
MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:coord];
[geocoder setDelegate:self];
[geocoder start];
Then I have these 2 methods
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {
NSLog(@"The geocoder has returned: %@", placemark.postalCode);
}
-(void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error {
NSLog(@"Error: %@", [error description]);
}
The question is , how can I get the zipcode in the url?
Thank you and please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你的问题中已经有了答案。
placemark.postalcode
由您的邮政编码组成。只要确保所有变量都包含正确的值即可。
如果我答对了你的问题,应该是答案。
You have already the answer in your question.
placemark.postalcode
consists of your zipcode.Just make sure, that all your variables consist the right value.
Should be the answer, if i get your question right.
您必须在此方法中传递坐标。所以检查坐标是否不为零。我想这就是你想要的。
You have to pass coordinate in this method. So check if coord is not nil.I guess this is what you want.
哦好吧,忘了吧。。
我错过了一些东西,抱歉
你是
CLLocationManager
的子类吗???如果没有,为什么要这样分配:
locationManager = [[HoCLController alloc] init];
而不是这样:self.locationManager = [[CLLocationManager alloc] init];
如果我弄错了,我很抱歉,但我想我正在给你答案..Oh Ok, forget it..
I miss something, sorry
Are you subclassing
CLLocationManager
???If not, why are you allocating like this:
locationManager = [[HoCLController alloc] init];
instead of this:self.locationManager = [[CLLocationManager alloc] init];
I'm sorry if I'm getting something wrong, but think i'm giving you the answer..