【发布时间】:2012-03-07 22:46:11
【问题描述】:
我想在 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];
这段代码应该已经将详细视图推到顶部并显示了详细视图,但它不喜欢,
任何帮助将不胜感激,我想做的是当有人点击地图视图上注释的右侧按钮时,我想显示一个详细视图,提前谢谢你..
【问题讨论】:
-
您可能会在这个问题stackoverflow.com/questions/8285153/…中找到有用的信息
标签: xcode mkmapview pushviewcontroller mkannotationview mkpinannotationview