1

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で変更されたものはありますか?

4

2 に答える 2

0

Xcode 4.6.1 を使用したシミュレーターではズーム レベルが改善されましたが、実際の iOS 6 デバイスではまだ制限されていました。これらのデバイスを iOS 6.1.3 に更新するまでは、ズームは iOS 6 レベルに戻ったようです。

于 2013-03-25T19:25:48.763 に答える
0

はい、iOS 6 で最大ズーム レベルが変更されました。Xcode 4.6 DP1 をダウンロードすると、結果のビルドが同じに近くなると聞きました (iOS 5 と iOS 6 の間)。

于 2013-01-01T20:30:14.577 に答える