实例化时,带有SwiftUI的HEREMaps会因EXC_BAD_INSTRUCTION崩溃

时间:2019-11-15 03:52:37

标签: swiftui here-api

我正在尝试通过 UIViewRepresentable 在SwiftUI中使用HEREMaps,并且在实例化NMAMapView时遇到以下崩溃。使用HEREMaps版本3.13.3 pod。

  

线程1:EXC_BAD_INSTRUCTION(代码= EXC_I386_INVOP,子代码= 0x0)

import SwiftUI
import NMAKit

struct MapView: UIViewRepresentable {

    func makeUIView(context: Context) -> NMAMapView {
        let mapView = NMAMapView()
        return mapView
    }

    func updateUIView(_ uiView: NMAMapView, context: Context) {

    }
}

struct ContentView: View {
    var body: some View {
        MapView()
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

此外,在我的Inof.plist中添加NSLocationWhenInUseUsageDescription也不算运气

2 个答案:

答案 0 :(得分:0)

我们已经编写了一个示例代码来初始化NMAPView。尝试以下操作

import UIKit
import NMAKit

class ViewController: UIViewController {

    @IBOutlet weak var mapView: NMAMapView!

    private var gestureMarker: NMAMapMarker?

    override func viewDidLoad() {
        super.viewDidLoad()
        //set current controller to be delegate of map view's gesture
        mapView.gestureDelegate = self

        //add image icon to show current positon, which can shows map view motion when gestures were applied
        guard let image = UIImage(named: "indicator") else { return }
        let indicatorMarker = NMAMapMarker(geoCoordinates: mapView.geoCenter, image: image)
        mapView.add(mapObject: indicatorMarker)
    }

答案 1 :(得分:0)

这是此处的SDK问题。不幸的是,尚未找到解决方法。

修复将包含在计划于2020年4月1日的下一个HERE SDK版本(3.15)中。

感谢举报!