0

地図の種類をハイブリッド、衛星、標準に変更するGoogleマップの機能を再現しようとしています。部分的なカールトランジションで表示されるビューを設定しました。このビュー内には、UISegmentedControlがあります。値が変更されると、次のコードが実行されます。

- (IBAction)setMap:(id)sender {
switch (((UISegmentedControl *) sender).selectedSegmentIndex) {
    case 0:
        [self curlViewControllerDidFinish:nil];
        [mapview setMapType:MKMapTypeStandard];
        break;

    case 1:
        [self curlViewControllerDidFinish:nil];
        [mapview setMapType:MKMapTypeSatellite];
        break;

    case 2:
        [self curlViewControllerDidFinish:nil];
        [mapview setMapType:MKMapTypeHybrid];
        break;

    }
}

カール遷移は終了しますが、mapTypeは変更されません。[mapview setmapType...上記を入れてみました[self curlViewControllerDidFinish...

注:[mapview setMapType:MKMapTypeHybrid];curlトランジションの外部で実行された場合、1行のコードでmapTypeを変更します。

これを修正する方法について何かアイデアはありますか?

4

1 に答える 1

2

iOS Maps.appは、ほとんどの場合、デリゲートを使用して、モーダルビューが新しいオプションを選択したことをマップビューに通知します。このようなもの:

- (IBAction)setMap:(id)sender {
switch (((UISegmentedControl *) sender).selectedSegmentIndex) {
    case 0:
        [self curlViewControllerDidFinish:nil];
        [self.delegate setMapType:MKMapTypeStandard];
        [self dismissModalViewControllerAnimated:YES];
        break;

    case 1:
        [self curlViewControllerDidFinish:nil];
        [self.delegate setMapType:MKMapTypeSatellite];
        [self dismissModalViewControllerAnimated:YES];
        break;

    case 2:
        [self curlViewControllerDidFinish:nil];
        [self.delegate setMapType:MKMapTypeHybrid];
        [self dismissModalViewControllerAnimated:YES];
        break;

    }
}
于 2012-03-27T01:46:53.263 に答える