我有一个应用程序,使用MapKit布局与注释地图。我有一个方法可以创建一个MKCoordinateRegion,将其分配给setRegion以适当调整地图的缩放级别。但是IOS 6中的缩放级别比IOS 5中的低。当我在IOS 5上运行时,注释间隔很好,但在IOS 6中,它们正好处于边缘。如果我调高比例因子,我可以在IOS 6中获得空间,但是在IOS 5中它们都在中间被卡在一起。MapView地区缩放级别不同在IOS 6
- (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;
}
设定在2.0以上的作品很好的IOS 6和1.3的作品很好的IOS 5的比例因子是什么奇怪的是IOS 6模拟器显示注释作为IOS 5只是它以同样的方式在iPhone 4S我用于测试它显示不正确。 IOS 6中是否有变化会影响缩放级别?