domesticcatsoftware / DCRoundSwitch

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

UIView Animations For Value Changed #30

Open ablackwoodim3 opened 11 years ago

ablackwoodim3 commented 11 years ago

[UIView animateWithDuration...] methods don't work when called in response to the switch's value being changed. This can be fixed very easily by replacing these lines in setOn:animated:ignoreControlEvents:

if (previousOn != on && !ignoreControlEvents) [self sendActionsForControlEvents:UIControlEventValueChanged];

with:

if (previousOn != on && !ignoreControlEvents) { [CATransaction begin]; [CATransaction setDisableActions:NO]; [self sendActionsForControlEvents:UIControlEventValueChanged]; [CATransaction commit]; }

gureckis commented 11 years ago

I can confirm that this fixes this bug for me.

wyefei commented 11 years ago

If a ModalViewController's view has DCRoundSwitch, then there will be no animation if dismissing it. @ablackwoodim3 work fixed it too. I went insane for 3 hours and thanks for the fix

npersson commented 10 years ago

Thank you so much, I nearly went bananas looking for this error!