domesticcatsoftware / DCRoundSwitch

A 'modern' replica of UISwitch.
MIT License
765 stars 162 forks source link

Continuos jumping state on-off #33

Open dral3x opened 11 years ago

dral3x commented 11 years ago

In my app I prepare the switch state and observe the UIControlEventValueChanged event on it, to change some internal state. The problem is that I receive the UIControlEventValueChanged event even if I set the state of the switch. With UISwitch object this doesn't happen.

The problem come from the last parameter on the setOn:animated: method in DCRoundSwitch class

- (void)setOn:(BOOL)newOn animated:(BOOL)animated
{
    [self setOn:newOn animated:animated ignoreControlEvents:NO];
}
kamarshad commented 10 years ago

I am facing the same issue as dral3x mentioned. As i toggle the Switch, it's action method called continuously automatically.

After I have changed the method call and passing YES flag as following [self setOn:newOn animated:animated ignoreControlEvents:YES];

Then it's action method does not call on toggling "On/Off".

Can anyone tell me what's wrong in the code and how can i fix this issue.

Thanks, Kamarshad