max*_*ax_ 2 objective-c uiview mkmapview ios
我在MKMapView中添加了一些注释,当用户点击其中一个注释时,它会显示一个带有正确附件按钮的UICalloutView,它会向地图添加一个UIView,显示有关该特定位置的一些信息.这个UIView以地图的超视图为中心,为了显示该视图中的信息是相对于注释的,我想将可见地图rect向下移动(在y轴上),并将其置于x轴使注释直接位于视图下方.
我正在执行以下操作以使注释居中,但是,我不知道如何在y轴上向下移动注释以使其位于添加的UIView下面.请问您能告诉我怎么做?
[self.mapView setCenterCoordinate:[annotation coordinate] animated:YES];
Run Code Online (Sandbox Code Playgroud)
如果你想将地图向下移动以使其以特定的方式为中心coordinate
,但是将其向下移动,比如40%,那么你可以在其上面留出空间,你可以做如下的事情:
CLLocationCoordinate2D center = coordinate;
center.latitude -= self.mapView.region.span.latitudeDelta * 0.40;
[self.mapView setCenterCoordinate:center animated:YES];
Run Code Online (Sandbox Code Playgroud)