У меня есть аннотации в MKMapView с выносками. В этих выносках есть кнопка «Стрелка вправо». При нажатии на нее, я хочу, чтобы открыть детальный вид, дополнительный UIViewController с его собственным пером файл и т.д. Я использую следующий код:Кнопка выноска аннотации MKMapView для подробного просмотра?
В моей MapViewController:
- (void)showDetails:(id)sender {
// the detail view does not want a toolbar so hide it
[self.navigationController setToolbarHidden:YES animated:NO];
NSLog(@"pressed!");
[self.navigationController pushViewController:self.detailViewController animated:YES];
NSLog(@"pressed --- 2!");
}
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(Annotation *) annotation {
if(annotation == map.userLocation) return nil;
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKPinAnnotationView* customPinView = [[[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease];
customPinView.pinColor = MKPinAnnotationColorRed;
customPinView.animatesDrop = YES;
customPinView.canShowCallout = YES;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
customPinView.rightCalloutAccessoryView = rightButton;
UIImageView *memorialIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"googlemaps_pin.png"]];
customPinView.leftCalloutAccessoryView = memorialIcon;
[memorialIcon release];
return customPinView;
}
кнопка работает, потому что, когда я введите NSLog внутри метода showDetais, он будет напечатан на консоли. Проблема в том, что ничего не происходит. При нажатии кнопки это похоже на отсутствие кнопки. Нет отладочной ошибки или исключения, просто ничего.
заголовок MapView выглядит примерно так:
@interface MapViewController : UIViewController <MKMapViewDelegate> {
MKMapView *map;
NSMutableDictionary *dictionary;
EntryDetailController *detailViewController;
}
@property (nonatomic,retain) IBOutlet MKMapView *map;
@property (nonatomic,retain) IBOutlet EntryDetailController *detailViewController;
Может быть кто-то из вас может помочь мне :)
Спасибо!