本文介绍了调用startNavigationWithSettings(navSettings)时为EXC_BAD_ACCESS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Skobbler的处理导航事件代码段设置了一个示例.当我打电话

I setup an example using Skobbler's Handling navigation events snippet. When I call

SKRoutingService.sharedInstance().startNavigationWithSettings(navSettings)

我得到EXC_BAD_ACCESS.这是代码:

override func viewDidLoad() {
        super.viewDidLoad()
        let mapView = SKMapView(frame: CGRectMake( 0.0, 0.0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)))
        mapView.delegate = self
        self.view.addSubview(mapView)

        SKRoutingService.sharedInstance().routingDelegate = self
        SKRoutingService.sharedInstance().navigationDelegate = self
        SKRoutingService.sharedInstance().mapView = mapView

        var route = SKRouteSettings()
        route.startCoordinate = CLLocationCoordinate2DMake(37.9667, 23.7167)
        route.destinationCoordinate = CLLocationCoordinate2DMake(37.9677, 23.7567)
        route.shouldBeRendered = true
        route.numberOfRoutes = 1
        SKRoutingService.sharedInstance().calculateRoute(route)
}

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func routingService(routingService: SKRoutingService!, didFinishRouteCalculationWithInfo routeInformation: SKRouteInformation!) {

        routingService.zoomToRouteWithInsets(UIEdgeInsetsZero)

        var navSettings = SKNavigationSettings()
        navSettings.navigationType = SKNavigationType.Simulation
        navSettings.distanceFormat = SKDistanceFormat.Metric
        SKRoutingService.sharedInstance().mapView.settings.displayMode = SKMapDisplayMode.Mode3D
        SKRoutingService.sharedInstance().startNavigationWithSettings(navSettings)
    }

推荐答案

问题是未配置SKRoutingService的audioAdvisorSettings属性.

The problem is that the audioAdvisorSettings property of the SKRoutingService is not configured.

    SKAdvisorSettings = SKAdvisorSettings() 
    settings.advisorVoice = "en_us"; 
    SKRoutingService.sharedInstance().advisorConfigurationSettings = settings

这篇关于调用startNavigationWithSettings(navSettings)时为EXC_BAD_ACCESS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 07:53