简体   繁体   English

MQMapView setRegion:导致应用程序崩溃

[英]MQMapView setRegion: causes app to crash

I'm trying to center my mapView on the user's location, but an exception is thrown that's caught by the AppDelegate before the mapView or view controller are even loaded. 我试图将mapView居中放置在用户的位置上,但是在加载MapView或视图控制器之前, AppDelegate引发了异常。

mapView is an MQMapView userLocation is assigned earlier from mapView.userLocation.location.coordinate mapView是一个MQMapView userLocation,是先前从mapView.userLocation.location.coordinate分配的

MQCoordinateSpan userSpan = MQCoordinateSpanMake(1000, 1000);

MQCoordinateRegion userRegion = MQCoordinateRegionMake(userLocation, userSpan);

[mapView setRegion:userRegion animated:true];

As far as I can make out from the MapQuest developer guide I'm calling setRegion correctly. 据我从MapQuest开发人员指南中了解到的,我正在正确地调用setRegion。 Any idea what might be causing the exception? 任何想法可能导致异常的原因吗?

I was having crashes with my iPhone4S and console revealed nan values for region. 我的iPhone4S崩溃了,控制台显示了区域的Nan值。 After trying about 7 different solutions from SO and various suggestions from Apple DTS, I solved it by eliminating the regionThatFits call. 在尝试了SO的7种不同解决方案以及Apple DTS的各种建议之后,我通过消除regionThatFits呼叫解决了它。 I simply used: 我只是用了:

CLLocationDistance visibleDistance = 100000; // 100 kilometers
MKCoordinateRegion adjustedRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, visibleDistance, visibleDistance);

[_mapView setRegion:adjustedRegion animated:YES];

Apparently there is a problem with that regionThatFits method. 显然该regionThatFits方法存在问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM