调用startNavigationWithSettings(navSettings)时EXC_BAD_ACCESS

时间:2015-03-04 16:33:52

标签: swift navigation skmaps

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

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

1 个答案:

答案 0 :(得分:1)

问题是没有配置SKRoutingService的audioAdvisorSettings属性。

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