9.24. The use of IOS switch

发布时间 :2025-10-25 12:23:54 UTC      

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

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.