MapKitを使用して注釈付きの地図をレイアウトするアプリがあります。マップのズームレベルを適切に調整するためにsetRegionに割り当てるMKCoordinateRegionを作成するメソッドがあります。ただし、IOS6のズームレベルはIOS5よりも低くなっています。IOS5で実行すると、注釈の間隔は適切になりますが、IOS6では注釈が端まで出ています。スケーリング係数を上げると、IOS 6で間隔を正しく設定できますが、IOS 5では、それらがすべて中央で詰まっています。
- (MKCoordinateRegion)calculateRegion
{
MKCoordinateRegion region;
double scaleValue = 1.5
//set an initial value for coordinates from any annotation
MyAnnotation *annotation = [self.annotations lastObject];
CLLocationCoordinate2D max = annotation.coordinate;
CLLocationCoordinate2D min = max;
double latitude, longitude;
for (MyAnnotation *annotation in self.annotations) {
latitude = annotation.coordinate.latitude;
longitude = annotation.coordinate.longitude;
if (latitude > max.latitude) max.latitude = latitude;
else if (latitude < min.latitude) min.latitude = latitude;
if (longitude > max.longitude) max.longitude = longitude;
else if (longitude < min.longitude) min.longitude = longitude;
}
// set the center of the mapview
region.center.latitude = (max.latitude + min.latitude) / 2;
region.center.longitude = (max.longitude + min.longitude) / 2;
// set the span to be larger than the max values to add some padding around pins
region.span.latitudeDelta = (max.latitude - min.latitude) * scaleValue;
region.span.longitudeDelta = (max.longitude - min.longitude) * scaleValue;
MKCoordinateRegion regionThatFits = [self.mapView regionThatFits:region];
region = regionThatFits;
return region;
}
scaleFactorを2.0より上に設定すると、IOS 6で適切に機能し、1.3はIOS 5で適切に機能します。奇妙なことに、IOS6シミュレーターはIOS5と同じように注釈を表示します。テストに使用しているiPhone4Sだけです。正しく表示されないこと。ズームレベルに影響を与えるIOS6で変更されたものはありますか?