在 iPad 的地图应用程序上,当您点击图钉时,您会看到带有“i”的普通注释,而不是公开指示符。进一步点击“i”会显示一个像这样的弹出视图控制器。
有没有办法可以轻松实现这一目标?
首先在地图上添加注释viewForAnnotation
方法,设置rightCalloutAccessoryView
到一个类型的按钮,例如 UIButtonTypeDetailDisclosure (我认为默认情况下蓝色信息按钮不可用)。
按下该按钮将调用calloutAccessoryControlTapped
委托方法。在此方法中,取消选择注释并显示弹出窗口。例如:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
[mapView deselectAnnotation:view.annotation animated:YES];
YourContentViewController *ycvc = [[YourContentViewController alloc] init...
UIPopoverController *poc = [[UIPopoverController alloc] initWithContentViewController:ycvc];
[ycvc release];
//hold ref to popover in an ivar
self.annotationPopoverController = poc;
//size as needed
poc.popoverContentSize = CGSizeMake(320, 400);
//show the popover next to the annotation view (pin)
[poc presentPopoverFromRect:view.bounds inView:view
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[poc release];
}
YourContentViewController 是 UIViewController 的子类,您可以像任何其他视图控制器一样编码。地图应用程序看起来内容中有 UITableView。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)