MKMapView : setRegion doesn't work !

浪子不回头ぞ 提交于 2019-11-29 02:37:11

I don't understand exactly the previous logs, but I know where was my error.

The instancied MKMapView was not initialised with a frame, but with an autoresizingMask set to > 0.

When the setRegion method was called, my view was not framed yet. I think the region values are calculated according to the view frame, so these values couldn't be found.

Just set the frame before doing a setRegion, and it would display normally.

Bye !

Your first log uses self.region.center.latitude, but I don't see that anywhere in your call to MKCoordinateRegionMake. The log is telling you that whatever you are using to make the region to set, has a lat/long of 0/0...

Setting the AutoResizing Mask helped me.

[_mapView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];   
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!