MKDirections计算方向WithCompletionHandler永远不会被触发

时间:2014-12-31 20:13:27

标签: objective-c ipad dictionary ios8 map-directions

当我发出指示请求时,永远不会触发完成处理程序。正确填充CL / MK地标并将其注入MKDirections对象。不知道如何继续调试这个。有什么帮助吗?

以下是方法:

-(void)getRouteWithPlacemark:(CLPlacemark*)clPlacemark
{
    MKDirectionsRequest *directionsRequest = [[MKDirectionsRequest alloc] init];
    MKPlacemark *placemark = [[MKPlacemark alloc] initWithPlacemark:clPlacemark];
    mapView.showsUserLocation = YES;
    if(routeIndex > 0){
        [directionsRequest setSource:[[MKMapItem alloc] initWithPlacemark:previousPlacemark]];
    }else{
        [directionsRequest setSource:[MKMapItem mapItemForCurrentLocation]];
    }
    previousPlacemark = [[MKPlacemark alloc] initWithPlacemark:placemark];
    [directionsRequest setDestination:[[MKMapItem alloc] initWithPlacemark:placemark]];
    directionsRequest.transportType = MKDirectionsTransportTypeAutomobile;
    MKDirections *directions = [[MKDirections alloc] initWithRequest:directionsRequest];
    [directions calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response, NSError *error) {
        if(error){
            NSLog(@"Error %@", error.description);
        }else{
            routeDetails = response.routes.lastObject;
            [mapView addOverlay:routeDetails.polyline];
            [self addAnnotation:clPlacemark];

            [self populateManeuversArrayWithRoute:routeDetails];

            if(routeIndex == [packageArray count] - 1){
                [self zoomMap];
                indicatorOverlay.hidden = YES;
                routeIndex = 0;
            }else{
                routeIndex++;
                [self getDirectionsWithCRMDataPackageArray:packageArray];
            }
        }
    }];

}

0 个答案:

没有答案