我希望有人帮我找到解决方法,如何添加或连接分割maptype(标准,卫星,混合)到我的主视图控制器。
答案 0 :(得分:2)
试试这个
- (void)viewDidLoad
{
segControl = [[UISegmentedControl alloc]initWithItems:[NSArray arrayWithObjects: @"One", @"Two", @"Three", nil]];
[segControl addTarget:self action:@selector(indexDidChangeForSegmentedControl:) forControlEvents:UIControlEventValueChanged];
[segControl setFrame:CGRectMake(50,20,200,44)];//set frame which you want
[self.view addSubview:segControl];
}
- (void)indexDidChangeForSegmentedControl:(UISegmentedControl *)aSegmentedControl {
switch (aSegmentedControl.selectedSegmentIndex) {
case 0:
map.mapType = MKMapTypeStandard;
break;
case 1:
map.mapType = MKMapTypeSatellite;
break;
case 2:
map.mapType = MKMapTypeHybrid;
break;
default:
break;
}
}