Detecting a change in UISwitch

后端 未结 8 1222
暖寄归人
暖寄归人 2021-02-18 14:19

This sounds trivial but I\'m noticing some weirdness. I\'ve wired up a handler for the Value Changed event of a UISwitch. What I would expect is that each time the hand

8条回答
  •  我在风中等你
    2021-02-18 14:49

       -(void) createSwitch
        {
            self.searchExistSearchNewSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0,0,0,0)];
            [self.searchExistSearchNewSwitch addTarget:self action:@selector(switchValueChanged:) forControlEvents:UIControlEventValueChanged];
            [self.view addSubview:self.searchExistSearchNewSwitch];
        }
        - (void)switchValueChanged:(UISwitch *)theSwitch
        {
            BOOL flag = theSwitch.isOn;
        }
    

提交回复
热议问题