我需要关于MapKit框架的帮助。我是iPhone开发的新手。我有一个从url加载的webview,它有3个参数,如下所示:
在视图控制器的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];然后我有这两个方法
- (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中的邮政编码?
谢谢,请帮帮忙。
发布于 2011-08-09 20:41:32
你的问题已经有答案了。placemark.postalcode由您的邮政编码组成。只需确保您的所有变量都包含正确的值。
zipcode = placemark.postalCode;如果我把你的问题回答对了,应该是答案。
发布于 2011-08-10 15:05:49
MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:coord]; 在此方法中,您必须传递坐标。所以检查coord是否不是nil.I,我猜这就是你想要的。
MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate];发布于 2012-01-04 02:05:31
哦,好吧,算了吧..我错过了一些东西,对不起
你是在继承CLLocationManager吗?如果不是,为什么要这样分配:locationManager = [[HoCLController alloc] init];而不是this:__self.locationManager = [[CLLocationManager alloc] init];如果我弄错了,我很抱歉,但我认为我给了你答案。
https://stackoverflow.com/questions/6996064
复制相似问题