Hey guys,
So i've created a custom TableViewCell, and in the nib I put a UISwitch. Before I had even hooked it up to anything, if I ran it in the simulator and clicked on it, it would switch from off to on with the animation and such.
I'm trying to add a feature where the user is only allowed to change from off to on when a certain condition is true. I want it so, when the user touches the switch, it checks if the condition is true, and if it isn't it the switch doesn't move.
I've set up an IBAction where if the user Touches Up Inside, it'll run my function. My function is this:
if([on_switch isOn])
{
if([my_switch canSwitchOn])
{
NSLog(@"SWITCHED ON SUCCESSFULLY");
[on_switch setOn:TRUE animated:TRUE];
}
else
{
NSLog(@"SWITCHED ON UNSUCCESSFULLY");
//Put in popup here
}
}
else
{
[[ClassesSingleton sharedSingleton] classSwitchedOff:cell_index];
[on_switch setOn:FALSE animated:TRUE];
}
However, no matter what I do, that switch will flip, even though I gave it no directions to do so. I'm pretty sure it's the auto-flip that cause it to do so even before I'd hooked anything up to it. Is there a way to turn that off?
Thanks!