【问题标题】:mapView in ios 9 simulator is blankios 9模拟器中的mapView是空白的
【发布时间】: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.
}

}

it's just a picture of the simulator once the app is run. This is what i meant when i said blank incase it wasn't clear.

提前致谢!

【问题讨论】:

  • 我认为您可能混淆了纬度和经度值。您现在拥有的纬度/经度将带您前往斯瓦尔巴群岛和扬马延(挪威北部偏远地区的几个偏远岛屿),但如果您转换纬度和经度,您将获得印度的海得拉巴。
  • 你的跨度太小了。尝试: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


【解决方案1】:

我认为您可能混淆了纬度和经度值。您现在拥有的纬度/经度会将您带到斯瓦尔巴群岛和扬马延(挪威北部偏远地区的几个偏远岛屿),但如果您转换纬度和经度,您会得到印度的海得拉巴。

【讨论】:

    【解决方案2】:

    只需打印值。 它可能是 0,0,您的位置将在海上。 请确保您的位置具有有效的位置。经度和纬度。


    当您尝试更新 ViewDidload 上的地图而不是查看 Didappear 时,总是会发生这种情况。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-05
      • 2021-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-09
      • 2015-12-15
      • 1970-01-01
      相关资源
      最近更新 更多