我希望有人帮助我找到解决方案,如何将分段映射类型(标准、卫星、混合)添加或连接到我的主视图控制器。
问问题
772 次
1 回答
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;
}
}
于 2013-06-18T17:54:19.103 回答