Search code examples
iosuiswitch

UISwitch - How do I not make it animate


I have a UISwitch that shows the password when it's ON and hides it when it's OFF. When it's clicked, an AlertView pops up asking for a password then confirm. My problem is the switch still switches to display the OFF text instead of it still being ON when the user clicks on it/enters the wrong password. I need it to still read the ON status/text until the user successfully enters the correct password on the alertview.


Solution

  • Step 1 in your interface do this

    IBOutlet UISwitch *passwordSwitch;
    

    Step 2 set your switch to the above

    Step 3 Upon your logic if the password fails do this

        passwordSwitch.on=NO;
    

    Edit:

    If it succeed do this

        passwordSwitch.on=YES;