首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >健全性检查MKCoordinateRegion

健全性检查MKCoordinateRegion
EN

Stack Overflow用户
提问于 2010-02-02 22:24:38
回答 1查看 4.1K关注 0票数 7

有没有什么方法可以快速测试MKCoordinateRegion的好坏?我将纬度换成了经度,并导致应用程序崩溃。我希望在实际执行之前能够查看是否有可能执行setRegionMKCoordinateRegionMake会测试我给它的值吗?

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-02-04 12:54:16

原来我在什么地方把纬度和经度调换了。下面是我最终使用的代码:

代码语言:javascript
复制
// check for sane span values
if (currentRegion.span.latitudeDelta <= 0.0f || currentRegion.span.longitudeDelta <= 0.0f) {
    currentRegion.span.latitudeDelta = 1.0f;
    currentRegion.span.longitudeDelta = 1.0f;
}
// check for sane center values
if (currentRegion.center.latitude > 90.0f || currentRegion.center.latitude < -90.0f ||
    currentRegion.center.longitude > 180.0f || currentRegion.center.longitude < -180.0f
    ) {
    // Take me to Tokyo.
    currentRegion.center.latitude = 35.4f;
    currentRegion.center.longitude = 139.4f;
}
票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2184675

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档