I am adding the UISwitch programmatically in a scroll view.
UIVIew -> UIScrollView -> UISwitch
UISwitch *toggleSwitch = [[UISwitch alloc] initWithFrame: CGRectZero];
[toggleSwitch addTarget:self action:@selector(flipMode:) forControlEvents:UIControlEventValueChanged];
toggleSwitch.on = YES;
toggleSwitch.userInteractionEnabled = YES;
[scrollView addSubview: toggleSwitch];
Action method:
- (IBAction)flipMode:(id)sender{
if([sender isOn])
{
// On Toggle ON
} else {
//On Toggle OFF
}
}
When we toggle the switch multiple times or on dragging or moving the switch slowly from ON to OFF state or vice versa at some point of time the action is not getting called. In next moment on value change it will trigger the event.
Occurrence of this issue is 2 out of 15-20 trials. Unable to find the root cause for it.
Help appreciated