当我执行以下代码片段时,地图会正确缩放以包含所有注释,但标注部分偏离屏幕。解决这个问题最优雅的方法是什么?当我缩放我的地图视图以显示我的注释时,所选注释部分偏离屏幕
func mapView(mapView: MKMapView!, didAddAnnotationViews views: [AnyObject]!) {
// once annotationView is added to the map, get the last one added unless it is the user's location:
if let annotationView = views.last as? MKAnnotationView where !(annotationView.annotation is MKUserLocation) {
// show callout programmatically:
mapView.selectAnnotation(annotationView.annotation, animated: false)
// zoom to all annotations on the map:
mapView.showAnnotations(mapView.annotations, animated: true)
}
谢谢。我最终用UIEdgeInsets进行了一个自定义函数。我想任何一种方法都有点离合。 – Zoef