开发者

MKMapView not displaying map

开发者 https://www.devze.com 2023-02-06 01:42 出处:网络
*Note this works perfectly in xcode and is only a problem on a iPhone running IOS 4.2.1 When I set the map to fit a region it does not refresh the map until I touch the screen. The bit of code I use

*Note this works perfectly in xcode and is only a problem on a iPhone running IOS 4.2.1

When I set the map to fit a region it does not refresh the map until I touch the screen. The bit of code I use is:

MKCoordinateRegion scaledRegion = [mapView regionThatFits:region];
[mapView setRegion:scaledRegion animated:YES];

This does move the map to the correct region which I can see when I touch the screen but until I touch the screen I get a grey screen with lots of grid lines across it.

It almost seems like the map is waiting for some sort of refresh event. I have also tried the following code with no success.

MKCoordinateRegion scaledRegion = [m开发者_如何学JAVAapView regionThatFits:region];
[mapView setRegion:scaledRegion animated:YES];
[mapView setCenterCoordinate:mapView.region.center animated:NO];

It is also worth noting this is running in a thread.

Thanks in advance for any help.


Very weird I have turned off the animation with the following code

[mapView setRegion:scaledRegion animated:YES];

to

[mapView setRegion:scaledRegion animated:NO];

And it has started working? I do not understand why?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号