【发布时间】:2016-04-17 16:14:47
【问题描述】:
使用 xcode v7.2.1 和 ios 模拟器 v9.2 时遇到问题。 我面临的问题是当我运行应用程序时地图显示为空白。 网格线出现一秒钟,然后它只是空白。我已经尝试寻找解决方案,但没有找到任何有效的解决方案。
import UIKit
import MapKit
class ViewController: UIViewController, MKMapViewDelegate {
@IBOutlet var map: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
//maps integration
let longitude : CLLocationDegrees = 17.486374
let latitude : CLLocationDegrees = 78.543345
let longDelta : CLLocationDegrees = 0.1
let latDelta : CLLocationDegrees = 0.1
let location : CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
let span : MKCoordinateSpan = MKCoordinateSpanMake(latDelta, longDelta)
let region : MKCoordinateRegion = MKCoordinateRegionMake(location, span)
map.setRegion(region, animated: true)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
提前致谢!
【问题讨论】:
-
我认为您可能混淆了纬度和经度值。您现在拥有的纬度/经度将带您前往斯瓦尔巴群岛和扬马延(挪威北部偏远地区的几个偏远岛屿),但如果您转换纬度和经度,您将获得印度的海得拉巴。
-
你的跨度太小了。尝试:latDelta 为 0.155,longDelta 为 0.26。如果它不起作用,请尝试增加值。它会渲染。但是随着您现在提供的跨度,它被放大得如此之多以至于看起来是空白的。我刚刚对此进行了测试。
-
@DrBeardface 非常感谢..那有效。但即使是偏远的岛屿,为什么它是空白的?是因为它们没有映射吗?
-
@rohanKumar 似乎在 iPhone 6 (9.2) 模拟器上线条仍然存在,但在 6 Plus (9.2)、6s (9.2) 和 6s Plus (9.2) 等其他模拟器上线条消失了.奇怪的。 (同样在 5 秒(9.2)时,线条明显消失。)
-
@DrBeardFace 在我尝试过的所有模拟器(包括 iPhone 6 (9.2))上,这些线条出现了一秒钟并消失了。对我来说,模拟器上的行为基本相同......我想知道为什么会发生这种情况。我正在使用 xcode 7.2.1。到目前为止,我是这方面的菜鸟,所以我不知道 xcode 版本是否有所作为。对于如何充分利用文档,我也很感激。其中很多都使用行话,我发现很难解读。你能想到什么?
标签: ios xcode swift ios-simulator mapkit