MapView - Wrong positioning

Originator:aleks
Number:rdar://9761939 Date Originated:12-Jul-2011 10:18 PM
Status:Resolved Resolved:8-Aug-2011
Product:iPhone SDK Product Version:iOS 5 beta 3
Classification:Serious Bug Reproducible:Always
 
Summary:

I have the following code that centered MapView right over Scandinavia (up to iOS 4.3.3):
 
CLLocationCoordinate2D center = { 62.674, 15.820 };
MKCoordinateRegion region = MKCoordinateRegionMake(center, MKCoordinateSpanMake(2, 2));
[mapView setRegion:region animated:YES];
 
But on iOS 5 beta (2, 3) it positions over Eastern Europe instead. I reviewed Release Changes documents to probably find some change in API or behavior, but found nothing there. So the question is why this code stopped working.

Steps to Reproduce:

Place the code above to viewDidLoad.

Expected Results:

After launch, the map is centered over Scandinavia with a zoom level that is enough to see Denmark, Norway and Sweden.

Actual Results:

I see the countries of Eastern Europe.

Notes:

I did some more playing, and looks like now it depends on where this code is placed. Previously it was in viewDidLoad and it positioned wrong. Then I placed it to viewWillAppear and it started to position correctly, but the zoom was now wrong, so I had to change the span too. This is really a bad sign, but looks like I will have to live with this workaround, checking on every appear whether this is really the very first one in a row.
 
One more thing, and I believe it's a revelation of one and the same bug, is that when a view with MKMapView is put into landscape mode, center stops being center. The tiles remain as if at the same position, but only some part of the fresh map is added at the right. In other words center moves to the left.

It's not only iPhone bug, it can be reproduced on iPad too.

Comments

Compile does not crash as of Apple Swift version 1.2 (swiftlang-602.0.37.3 clang-602.0.37).

Program compiles and runs correctly.

This issue has been verified as resolved and can be closed.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!