2017-07-27 13 views
2

私はポリライン描画に問題があります。私はiOS 11ベータ4の問題であると推測しました。同じコードで昨日動作していましたが、今はベータ4にアップデートしました。ポリラインを描きません。iOS11 beta 4でポリラインを描画する際の問題?

iOS 10.3シミュレータのXcode 8とiOS 11b4シミュレータのXcode 9b4で試してみてください。

コード:

import MapKit 

class ViewController: UIViewController, MKMapViewDelegate { 

    let mapView = MKMapView() 

    override func viewDidLoad() { 
     super.viewDidLoad() 

     mapView.frame = CGRect(x: 10, y: 10, width: 300, height: 300) 
     mapView.delegate = self 
     mapView.region = MKCoordinateRegionMake(CLLocationCoordinate2D(latitude: 51.482736, longitude: -0.015253), MKCoordinateSpanMake(0.005, 0.005)) 
     mapView.delegate = self 

     let coordinate1 = CLLocationCoordinate2D(latitude: 51.482736, longitude: -0.015253) 
     let coordinate2 = CLLocationCoordinate2D(latitude: 51.482736, longitude: -0.016253) 

     let polyline = MKPolyline(coordinates: [coordinate1, coordinate2], count: 2) 

     mapView.add(polyline, level: .aboveLabels) 

     view.addSubview(mapView) 
    } 

    func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { 
     let renderer = MKPolylineRenderer(overlay: overlay) 

     renderer.strokeColor = UIColor.red 
     renderer.lineWidth = 4.0 

     return renderer 
    } 
} 

iOSの10: enter image description here

iOSの11: enter image description here

注釈は問題なくマップに追加されます。

+1

私は同じ問題を抱えています。それをios11に表示するためにできることは何ですか? – davidk

+0

ベータ版待ち5 – Andrew

+2

私のコードでは、最初にポリラインが表示されないようです。ただし、地図をズームイン/ズームアウトすると表示されます。 – davidk

答えて

1

ベータ5で修正されました。

関連する問題