我想在xcode中点击mapview注释上的右键后显示详细视图,但我无法显示视图,我的代码:
- (void)showDetails:(id)sender
{
[self.navigationController setToolbarHidden:YES animated:NO];
[self.navigationController pushViewController:self.detailViewController animated:YES];
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
static NSString* BridgeAnnotationIdentifier = @"bridgeAnnotationIdentifier";
MKPinAnnotationView* customPinView = [[[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:BridgeAnnotationIdentifier] autorelease];
customPinView.pinColor = MKPinAnnotationColorPurple;
customPinView.animatesDrop = YES;
customPinView.canShowCallout = YES;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSLog(@"%@",rightButton);
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
customPinView.rightCalloutAccessoryView = rightButton;
return customPinView;//[kml viewForAnnotation:annotation];
}
showDetails 方法被调用,但无法将 detailViewController 推到顶部,
[self.navigationController pushViewController:self.detailViewController animated:YES];
此代码应该已将详细视图推到顶部并显示详细视图,但它不喜欢,
任何帮助将不胜感激,我想做的是当有人点击地图视图上注释的右侧按钮时,我想显示详细视图,提前谢谢你..