Я добавил базу данных plist для хранения информации для аннотаций в MKMapView. Как только я реализовал код для получения информации, мои методы делегата больше не вызывались.
Код, который я добавил, был:
- (void)viewDidLoad
{
NSMutableArray *annotations = [[NSMutableArray alloc]init];
NSString *path = [[NSBundle mainBundle] pathForResource:@"MillersStores" ofType:@"plist"];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
NSArray *anns = [dict objectForKey:@"Root"];
for(int i = 0; i < [anns count]; i++) {
float realLatitude = [[[anns objectAtIndex:i] objectForKey:@"Latitude"] floatValue];
float realLongitude = [[[anns objectAtIndex:i] objectForKey:@"Longitude"] floatValue];
MillersLocations *myAnnotation = [[MillersLocations alloc] init];
CLLocationCoordinate2D theCoordinate;
theCoordinate.latitude = realLatitude;
theCoordinate.longitude = realLongitude;
myAnnotation.coordinate = theCoordinate;
myAnnotation.title = [[anns objectAtIndex:i] objectForKey:@"Title"];
myAnnotation.subtitle = [[anns objectAtIndex:i] objectForKey:@"Address"];
[mapView addAnnotation:myAnnotation];
[annotations addObject:myAnnotation];
[myAnnotation release];
}
}
И это один из методов делегата, который больше не вызывается:
- (MKAnnotationView *) mapView:(MKMapView *) mapView viewForAnnotation:(id ) annotation {
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
MKPinAnnotationView *pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil] autorelease];
pinView.pinColor = MKPinAnnotationColorRed;
pinView.animatesDrop = YES;
pinView.canShowCallout = YES;
UIImageView *leftIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"MillersAnnotation.png"]];
pinView.leftCalloutAccessoryView = leftIconView;
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.rightCalloutAccessoryView = rightButton;
return pinView;
}
У меня есть еще один метод делегата, который также увеличивает масштаб пользовательского местоположения, которое также не вызывается, а также метод calloutAccessoryControlTapped, который больше не вызывается.
Я знаю, что это как-то связано с новым кодом, но я запутался в том, как даже отладить это, потому что это не дает мне ошибок, и я не могу записать это, потому что целые методы даже не вызываются , Когда я избавляюсь от нового кода, старый код работает нормально ... Что в новом коде отрицает старый код?