EXC_BAD_ACCESS when calling startNavigationWithSettings(navSettings)

…衆ロ難τιáo~ 提交于 2019-12-11 11:53:52

问题


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

SKRoutingService.sharedInstance().startNavigationWithSettings(navSettings)

I get EXC_BAD_ACCESS. Here is the code:

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)
    }

回答1:


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

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


来源:https://stackoverflow.com/questions/28859800/exc-bad-access-when-calling-startnavigationwithsettingsnavsettings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!