9.24. The use of IOS switch

发布时间 : 2025-10-25 13:32:32 UTC      

Page Views: 10 views

The switch is used to switch between the on and off states.

Important attribute

  • OnImage

  • OffImage

  • On

9.24.1. An important method

- (void)setOn:(BOOL)on animated:(BOOL)animated 

9.24.2. Add custom methods addSwitch and switches

-(IBAction)switched:(id)sender{ NSLog(@"Switch current state %@", mySwitch.on ? @"On" : @"Off"); } -(void)addSwitch{ mySwitch = [[UISwitch alloc] init]; [self.view addSubview:mySwitch]; mySwitch.center = CGPointMake(150, 200); [mySwitch addTarget:self action:@selector(switched:) forControlEvents:UIControlEventValueChanged]; } 

9.24.3. Modify the viewDidLoad in ViewController.m, as follows

(void)viewDidLoad { [super viewDidLoad]; [self addSwitch]; } 

Output

Now when we run the application, we will see the following output

switchOutput1

The output of the right slide switch is as follows

switchOutput2

《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。