I have two UIView and link to the following files
1. FirstViewController.h and .m
2. MapTypeOption.h and .m
FirstViewController is link to MapTypeOption with Navigation control
I would like to perform the following task
Use a UI Segment Control at MapTypeOption to change
the Google map type in FirstViewController
so in FirstViewController.h I have a function as follow
- (void)ChangeMapType:(int )SelectIndex
my FirstViewController.m has a function as follow
-(void)ChangeMapType:(int )SelectIndex
{
switch (SelectIndex)
{
case 0:
MainMapView.mapType = MKMapTypeStandard;
break;
case 1:
MainMapView.mapType = MKMapTypeSatellite;
break;
case 2:
MainMapView.mapType = MKMapTypeHybrid;
break;
default:
MainMapView.mapType = MKMapTypeStandard;
break;
}
}
in MapTypeOption.m I have the following
#import "FirstViewController.h"
@class FirstViewController;
....
- (IBAction)updatemaptype:(id)sender
{
FirstViewController *newFirstViewControllerobj=[[FirstViewController alloc] init];
[newFirstViewControllerobj ChangeMapType:MapTypeSegment.selectedSegmentIndex];
}
I can compile and run my program (with simulator) but even I select a different
segment at MapTypeOption view nothing is changed in FirstViewController
您可能需要在ChangeMapType中调用[view setNeedsDisplay]来导致视图更新。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.