2

I have a mapview with a number of annotations on it , the user has the possibility to search for a specific annotation through a search modal screen . The logic is when the user selects an annotation from the search table the mapview conforms to a protocol in order to select the picked annotation already exists on the map . The above logic works fine on the simulator but when I tried on a real device the mapview is unable to select the annotation similarly it gives an error "ERROR: Trying to select an annotation which has not been added"

-(void)OrangePointsViewController:(OrangePointsViewController*)sender annotationForLocation:(NSDictionary *)location{
CLLocationCoordinate2D userLoc;
userLoc.latitude =  [[location objectForKey:ORANGE_POINT_LATITUDE] doubleValue];
userLoc.longitude = [[location objectForKey:ORANGE_POINT_LONGITUDE] doubleValue];
[self.mapView setRegion:MKCoordinateRegionMakeWithDistance(userLoc, 1000, 1000) animated:YES];
[self.mapView selectAnnotation:[OrangePointAnnotation annotationForOrangePoint:location] animated:YES];
}
poa
  • 269
  • 1
  • 4
  • 13
  • What does the method annotationForOrangePoint: do? What iOS version is the simulator? What iOS version is the real device? In iOS 6, I think there's a bug where selectAnnotation "works" even if you've never called addAnnotation. –  Oct 30 '13 at 16:57
  • annotationForOrangePoint returns an annotation , the simulator has iOS 6 as version while the device has iOS 7 as version. in between the annotation that I want to select is already on the map . – poa Oct 30 '13 at 19:38
  • Just I have tried with a device that it has iOS 6.0 and it worked.in order to make it work on iOS7 what should I do what are the steps ?many thanks in advance – poa Oct 30 '13 at 19:51
  • 2
    So that method creates a new instance of an annotation every time it's called? For selectAnnotation, you have to pass the same exact instance of the annotation that was passed to addAnnotation. This is regardless of iOS version. The fact that it seems to work in iOS 6 is due to a bug in the sdk. –  Oct 30 '13 at 20:01
  • that's great thank you very much all the best from Switzerland – poa Oct 30 '13 at 20:13

0 Answers0