在点击一个图钉时,在iPad上的地图应用程序中,您可以使用"i"而不是公开指示符获得正常注释.进一步点击"i"会显示这样的弹出视图控制器.

有没有办法轻松实现这一目标?
小智 58
首先在地图上添加一个注释,然后在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];
}
Run Code Online (Sandbox Code Playgroud)
YourContentViewController是UIViewController的子类,您可以像任何其他视图控制器一样编码.地图应用程序看起来在内容中具有UITableView.
| 归档时间: |
|
| 查看次数: |
20658 次 |
| 最近记录: |