6

iOS 7 用の iOS 6 アプリを更新していて、オーバーレイの処理方法が iOS 7 で完全に変更されていることを発見しました。

マップ全体に薄い灰色のオーバーレイを描画しています。iOS 6 ではすべてが完全に機能しますが、iOS 7 ではオーバーレイが表示されません。

私はviewDidLoad次のものを持っています:

CLLocationCoordinate2D worldCoords[4] = { {90,-180}, {90,180}, {-90,180}, {-90,-180} };
MKPolygon *worldOverlay = [MKPolygon polygonWithCoordinates:worldCoords
                                                      count:4];
[self.mapView addOverlay:worldOverlay];

次に、iOS 6 の場合。. .

- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id<MKOverlay>)overlay
{
    if (![overlay isKindOfClass:[MKPolygon class]]) {
        return nil;
    }
    MKPolygon *polygon = (MKPolygon *)overlay;
    MKPolygonView *view = [[MKPolygonView alloc] initWithPolygon:polygon];
    view.fillColor = [[UIColor darkGrayColor] colorWithAlphaComponent:0.4];
    return view;
}

iOS 7 の場合。. .

- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay
{
    if (![overlay isKindOfClass:[MKPolygon class]]) {
        return nil;
    }
    MKPolygon *polygon = (MKPolygon *)overlay;
    MKPolygonRenderer *renderer = [[MKPolygonRenderer alloc] initWithPolygon:polygon];
    renderer.fillColor = [[UIColor darkGrayColor] colorWithAlphaComponent:0.4];    
    return renderer;
}

ブレークポイントを使用して、mapView:rendererForOverlay:メソッドが呼び出されていることと、メソッドがrenderer返すオブジェクトのfillColorプロパティが正しく設定されていることを確認しました。

オーバーレイが表示されない理由について何か考えはありますか?

4

2 に答える 2

1

何度も試した結果、やっと世界地図が全て網羅されていることがわかりました。Apple は SDK を使用する方法を知りません。2 つのポリゴンを追加する必要があります。世界地図は 2 つの部分に分割されます。そしてオーバーレイに追加されました。境界定義のこれら 2 つの部分は次のとおりです。

 var ccoodsW = new CLLocationCoordinate2D[] {
                 new CLLocationCoordinate2D(){ Latitude = 85.9809906974076,Longitude = -179.999999644933 },
                 new CLLocationCoordinate2D(){ Latitude = -80.9793991796858,Longitude = -179.999999644933},
                 new CLLocationCoordinate2D(){ Latitude = -80.97939920061767,Longitude = 0},
                 new CLLocationCoordinate2D(){ Latitude = 85.9809906974076 ,Longitude = 0}
             };

        var ccoodsE = new CLLocationCoordinate2D[] {
                 new CLLocationCoordinate2D(){ Latitude = 85.9809906974076,Longitude = 0 },
                 new CLLocationCoordinate2D(){ Latitude = -80.9793991796858,Longitude = 0},
                 new CLLocationCoordinate2D(){ Latitude = -80.97939920061767,Longitude = 179.999999644933},
                 new CLLocationCoordinate2D(){ Latitude = 85.9809906974076 ,Longitude = 179.999999644933}
             };

ところで:私はiosにxamarinを使用しています

于 2014-01-07T11:36:27.173 に答える