ios 9 模拟器中的 mapView 是空白的
mapView in ios 9 simulator is blank
使用 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.
}
}
这只是应用程序 运行 后模拟器的图片。
这就是我说空白的意思,以防不清楚。
提前致谢!
我认为您可能混淆了纬度和经度值。 lat/long 您现在将带您前往斯瓦尔巴特群岛和扬马延岛(挪威北部荒野中的几个偏远岛屿),但如果您切换纬度和经度,您将到达印度的海得拉巴。
只需打印值。
它可能是 0,0 并且您的位置将在海上。
请确保您的位置具有有效位置。经度和纬度。
当您尝试在 ViewDidload 而不是视图 Didappear 上更新地图时,这种情况总是会发生。
使用 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.
}
}
这只是应用程序 运行 后模拟器的图片。 这就是我说空白的意思,以防不清楚。
提前致谢!
我认为您可能混淆了纬度和经度值。 lat/long 您现在将带您前往斯瓦尔巴特群岛和扬马延岛(挪威北部荒野中的几个偏远岛屿),但如果您切换纬度和经度,您将到达印度的海得拉巴。
只需打印值。 它可能是 0,0 并且您的位置将在海上。 请确保您的位置具有有效位置。经度和纬度。
当您尝试在 ViewDidload 而不是视图 Didappear 上更新地图时,这种情况总是会发生。