2016-09-30 4 views
10

enter image description hereMKmapViewオーバーレイの描画は、私はMKMapViewの上にMKPolyLineを描いていますカラーパッチiOSの10

を示しています。 iOS 10が正常に動作する前にiOS 10ではルート以外のカラーパッチを表示しています。

- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay 
{ 
[![enter image description here][1]][1]if ([overlay isKindOfClass:[MKPolyline class]]) { 
    MKPolyline *route = overlay; 
    @try { 

     MKPolylineRenderer *routeRenderer = [[MKPolylineRenderer alloc] initWithPolyline:route]; 
     routeRenderer.strokeColor = [UIColor colorWithRed:20/255.0 green:153/255.0 blue:255/255.0 alpha:1.0]; 
     routeRenderer.lineWidth = 3; 
     [routeRenderer setNeedsDisplay]; 
     return routeRenderer; 
    } 
    @catch (NSException *exception) { 
     NSLog(@"exception :%@",exception.debugDescription); 
    } 

} 
else return nil; 
} 

答えて

1

iOS 10のバグと同じように、私はこのバグを「ハックする」ために多くの時間を費やします。

MKPolylineを再描画するとき(古いものを削除して新しいものを追加する)、dispatch_afterで呼び出す必要があるのは1つのみの解決策でした。マップ作成時に再描画する必要があります。 (私見)

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ // Add MKPolyline to mapView });

それは、より多くのテストを必要ですが、それはそれは私が同じ問題を経験した

+0

おかげさま、お返事ありがとうございます。私は確認し、あなたに知らせる – Mahendra

0

を作品見て、何をされたときのMapViewデリゲートの呼び出し

​​

私もMKPolylineを再描画オーバーレイを追加するコードがviewDidLoadから呼び出されたということが私の問題を解決しました。 viewDidAppearにコードを移動すると、問題は解決されました。

+0

まあ...それでは十分ではありませんでした。 – dardi

+1

私はMKPolylineRendererを拡張し、 - (BOOL)canDrawMapRect:(MKMapRect)mapRectを上書きする必要がありました zoomScale:(MKZoomScale)zoomScaleは常にYESを返します。 – dardi

+0

ブール値をYESに設定して問題を解決しましたか? – GGirotto

関連する問題