I'm trying to recreate the feature of Google Maps that changes the map type to hybrid or satellite or standard. I have setup a view that's displayed in a partial curl transition. Within this view, is a UISegmentedControl. When it's value is changed, the following code is executed:
- (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;
}
}
The curl transition does finish, but the mapType does not change. I have tried putting the [mapview setmapType...
above the [self curlViewControllerDidFinish...
.
Note: [mapview setMapType:MKMapTypeHybrid];
does change the mapType with 1 line of code if executed outside of the curl transition.
Any ideas on how to fix this?
The iOS Maps.app most likely uses a delegate to inform the map view that the modal view has selected a new option. Something like this:
- (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;
}
}