ここで、注釈を選択すると、次のようにビューを中央に再配置します。
[mapView setCenterCoordinate:view.annotation.coordinate animated:YES];
しかし、ビューを水平方向ではなく垂直方向のみの中央に再配置するにはどうすればよいですか?
ここで、注釈を選択すると、次のようにビューを中央に再配置します。
[mapView setCenterCoordinate:view.annotation.coordinate animated:YES];
しかし、ビューを水平方向ではなく垂直方向のみの中央に再配置するにはどうすればよいですか?
注釈からの緯度と現在の経度を持つ新しい座標を作成します
CLLocationCoordinate2D newCenter = CLLocationCoordinate2DMake(view.annotation.coordinate.latitude, mapView.centerCoordinate.longitude);
以前と同じように設定します
[mapView setCenterCoordinate:newCenter animated:YES];
マップビューのYを維持しますが、Xの中央は次のようになります。
[mapView setCenterCoordinate:[self convertPoint:CGPointMake(view.annotation.coordinate.x /* or whatever x is in the coordinate sys*/, mapView.frame.origin.y) toCoordinateFromView:mapView] animated:YES];
ポイントをCLLocationCoordinate2Dに変換します。
- (CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(UIView *)view
これはあなたの問題をいくらか助けるはずです。幸運を。