我安装使用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)
}