我有一个带有许多注释的地图视图,用户可以通过搜索模式屏幕搜索特定的注释。逻辑是当用户从搜索表中选择一个注解时,mapview 遵循一个协议,以便选择地图上已经存在的选择注解。上述逻辑在模拟器上运行良好,但是当我在真实设备上尝试时,mapview 无法选择类似的注释,它会给出错误“错误:尝试选择尚未添加的注释”
-(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];
}