2017-09-30 71 views
1

一旦我启动应用程序,它应该加载你所在城市的地图。它在IOS 9-10中完美运行。由于iOS 11地图开始出现奇怪的行为。现在,当你启动应用程序时,它会显示黄色地图。如果我点击主页按钮,等待3-5秒,回到应用程序,它会显示地图应该...试图调试它,改变布局结构,没有什么帮助..下面你可以看到截图当你打开应用程序第一次和5秒后回到主屏幕。MKMapView无法加载地图并显示黄色背景

添加到这样的观点:

mapView.isScrollEnabled = false 
mapView.isZoomEnabled = false 
mapView.isPitchEnabled = false 
mapView.isRotateEnabled = false 
mapContainer.addSubview(mapView) 
mapView.fillSuperview() 

然后设置一下地图位置检测到这样的:

let center = CLLocationCoordinate2D(latitude: mapLatitude - 0.004, longitude: mapLongitude) 
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.04, longitudeDelta: 0.04)) 
self.mapView.setRegion(region, animated: true) 

Map view on app start enter image description here

+0

你在iOS模拟器或设备上尝试过吗? –

+0

@KosukeOgawa都 –

回答

-1

所以错误是错误的初始化。当我应该在viewDidLoad内部执行时,我在viewController的顶部初始化了mapview。这解决了这个问题。