SKRoutingService 在计算后没有缩放到路由是否存在已知错误?
接下来是我的案例场景:我在一个 View Controller 中有一个 field 列表。 当用户点击它们中的任何一个时,另一个 ViewController 将打开并在它们上面,将使用以下代码创建 SKMapView 的新实例:
-(void)initMap
{
_map = [[SKMapView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, _mapView.frame.size.height)];
//UIView* userInteractionBlocker = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, _mapView.frame.size.height)];
//[_mapView addSubview:userInteractionBlocker];
_map.settings.rotationEnabled = YES;
_map.settings.displayMode = SKMapDisplayMode2D;
_map.mapScaleView.hidden = YES;
//[map centerOnCurrentPosition];
//[map animateToZoomLevel:25.0];
[SKRoutingService sharedInstance].mapView = _map;
[SKRoutingService sharedInstance].routingDelegate = self;
SKRouteSettings* route = [[SKRouteSettings alloc]init];
route.startCoordinate=CLLocationCoordinate2DMake([Constants shared].selectedExit.lat, [Constants shared].selectedExit.lon);
route.destinationCoordinate=CLLocationCoordinate2DMake([Constants shared].selectedVenue.lat, [Constants shared].selectedVenue.lon);
UIImage *venuePin;
switch (_venue.primary_category) {
case 626:
venuePin = [UIImage imageNamed:@"pinGasBlack"];
break;
case 623:
venuePin = [UIImage imageNamed:@"pinHotelBlack"];
break;
case 593:
venuePin = [UIImage imageNamed:@"pinFoodYellow"];
break;
}
SKAnnotation* exit = [self createPinWithImage:[UIImage imageNamed:@"pinExitYellow"] atCoordinates:CLLocationCoordinate2DMake([Constants shared].selectedExit.lat, [Constants shared].selectedExit.lon) withIdentifier:@"pinExit" identifier:0];
SKAnnotation* venue = [self createPinWithImage:venuePin atCoordinates:CLLocationCoordinate2DMake([Constants shared].selectedVenue.lat, [Constants shared].selectedVenue.lon) withIdentifier:@"pinVenue" identifier:1];
[_map addAnnotation:exit withAnimationSettings:nil];
[_map addAnnotation:venue withAnimationSettings:nil];
[_mapView addSubview:_map];
[[SKRoutingService sharedInstance] calculateRoute:route];
}
- (void)routingService:(SKRoutingService *)routingService didFinishRouteCalculationWithInfo:(SKRouteInformation*)routeInformation{
[[SKRoutingService sharedInstance] zoomToRouteWithInsets:UIEdgeInsetsZero];
}
事情是,我第一次打开 field 屏幕时,路线被计算并完美缩放。
但是一旦我返回,选择另一个地点并到达 ViewController,应该在其中初始化另一个新 map 并将其缩放到路线位置,它就不会发生。 发生的事情是: - map 已初始化 - 计算路线 - map 注释位置完美
但它被缩小到显示一个行星地球...如此完全缩小,即使我设置了
[[SKRoutingService sharedInstance] zoomToRouteWithInsets:UIEdgeInsetsZero];
而且我查了下,路由计算后代码是可达的,但是就是不缩放?
有什么解决办法吗?
最佳答案
这是一个错误:调用 zoomToRouteWithInsets
两次
关于ios - 计算后 SKRoutingService 不缩放到路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31795340/