首页 > 解决方案 > 为什么 watchOS 5 应用程序中的地图不显示在模拟器中?

问题描述

我想在 watchkit 应用程序中显示地图。当我使用下面的代码时,我可以看到我的 pin 注释,但看不到地图本身。请参阅图片以获取说明。

在此处输入图像描述

我正在运行 Xcode 10.2.1。这个版本我只能在模拟器上运行,因为这个版本的 Xcode 不能在我的系列 4 手表上运行。请在下面查看我的代码:

 override func willActivate() {

        super.willActivate()

        location.latitude = (CLLocationDegrees(lat))
        location.longitude = (CLLocationDegrees(lon))

        locationManager = CLLocationManager()
        let spanX: Float = 0.005
        let spanY: Float = 0.005


        region.center = location
        region.span.latitudeDelta = CLLocationDegrees(spanX)
        region.span.longitudeDelta = CLLocationDegrees(spanY)
        stationMap.setRegion(region)


        stationMap.addAnnotation(location, with: .red)
    }

我可能会丢失或错误地调用地图。

标签: xcodemapkitwatchkit

解决方案


推荐阅读