我正在尝试获取MapAnnotation
用户单击的特定详细信息。详细信息是从plist
文件中获取的。对于我在使用此功能- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view;
时使用过的此功能。当我单击特定时,它会从as annotation
获取位置详细信息,并且它不会检查我的 plist 值。即使在我将这些值作为 plist 中的属性作为每个位置的 latlong 给出之后。任何人都可以解决我的问题?Map
"Pune, Maharashtra, India @ <+18.50565666,+73.85559082> +/- 0.00m"
我的 plist 文件详细信息:
2013-02-18 12:16:56.039 MapView[9407:13d03] {
contents = "This Fish will be Found Rarely in South Asia";
imagesName = "kfish.jpg";
latlong = "Bangalore, Karnataka, India @ <+12.98333330,+77.58333330> +/- 0.00m";
listName = kFish;
location = "Bangalore, Karnataka, India";
}
2013-02-18 12:16:56.039 MapView[9407:13d03] {
contents = "This Fish will be Found Rarely in South Asia";
imagesName = "wallfish.png";
latlong = "Delhi, India @ <+28.59100531,+77.08826373> +/- 0.00m";
listName = WallFish;
location = "Delhi, India";
}
2013-02-18 12:16:56.039 MapView[9407:13d03] {
contents = "This Fish will be Found Rarely in South Asia";
imagesName = "fish.jpg";
latlong = "Chennai, Tamil Nadu, India @ <+13.07983465,+80.24625757> +/- 0.00m";
listName = Fish;
location = "Chennai,TamilNadu,India";
}
2013-02-18 12:16:56.039 MapView[9407:13d03] {
contents = "This Fish will be Found Rarely in South Asia";
imagesName = "bluefish.jpg";
latlong = "Mumbai, Maharashtra, India @ <+18.99460885,+72.82287598> +/- 0.00m";
listName = BlueFish;
location = "Mumbai, Maharashtra, India";
}
2013-02-18 12:16:56.040 MapView[9407:13d03] {
contents = "This Fish will be Found Rarely in South Asia";
imagesName = "Rarefish.jpg";
latlong = "Chennai, Tamil Nadu, India @ <+13.07983465,+80.24625757> +/- 0.00m";
listName = RareFish;
location = "Chennai,TamilNadu,India";
}
我的编码:
- (void)geocodeRequest
{
CLGeocoder *geocoder = [[CLGeocoder alloc]init];
for (int i = 0; i < total; i++) {
NSString *address = [allValues objectAtIndex:i] ;
[geocoder geocodeAddressString:address completionHandler:^(NSArray *placemarks, NSError *error) {
CLPlacemark *geocodedPlacemark = [placemarks objectAtIndex:0];
MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:geocodedPlacemark.location.coordinate addressDictionary:geocodedPlacemark.addressDictionary];
int zoomLevel=20;
MKCoordinateRegion region=MKCoordinateRegionMake(geocodedPlacemark.location.coordinate, MKCoordinateSpanMake(zoomLevel,zoomLevel));
[self.mapView addAnnotation:placemark];
[self.mapView setRegion:region animated:YES];
[self.mapView setZoomEnabled:YES];
}];
}
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{
total = self.arrayImages.count;
NSArray *newIndex = [mapView selectedAnnotations];
NSLog(@"sel :%@",newIndex);
for (index = 0; index < total; index++) {
dict = [self.arrayImages objectAtIndex:index];
NSLog(@"%@",dict);
if (latlong == newIndex) {
CGRect rec = CGRectMake(0, 0, 250, 250);
[self setView:[[[UIView alloc] initWithFrame:rec] autorelease]];
[[self view] setBackgroundColor:[UIColor whiteColor]];
UIImage *img = [UIImage imageNamed:[dict objectForKey:@"imagesName"]];
UIImageView *im = [[UIImageView alloc] initWithImage:img];
UILabel *lab1 = [[UILabel alloc] init];
UITextView *detailsView = [[UITextView alloc] init];
lab1.text = [NSString stringWithFormat:[dict objectForKey:@"listName"]];
detailsView.text = [NSString stringWithFormat:[dict objectForKey:@"contents"]];
detailsView.editable = NO;
detailsView.bounds = CGRectMake(20, 20, 150, 150);
detailsView.frame = CGRectMake(210, 720, 390, 350);
detailsView.font = [UIFont systemFontOfSize:24];
lab1.bounds = CGRectMake(20, 20, 150, 150);
lab1.frame = CGRectMake(360, 600, 90, 50);
lab1.font = [UIFont systemFontOfSize:24];
im.bounds = CGRectMake(10, 10, 50, 50);
im.frame = CGRectMake(200, 120, 370, 450);
[UIView transitionWithView:[self view] duration:1.5
options:UIViewAnimationOptionTransitionCurlUp
animations:^ { [[self view] addSubview:im];
[[self view] addSubview:lab1];
[[self view] addSubview:detailsView];
}completion:nil];
}
}
}
MapView 工作正常。但仅在获取所选位置时它不起作用。谁能帮我我哪里出错了?
提前致谢。