10

I'm trying to set the UISwitch selected value and it's not responding!

Here is my code

I set the value to UISwitch. Default value is False.

[mailSwitch setSelected:TRUE];

Can someone help me.

HardCode
  • 2,025
  • 4
  • 33
  • 55

3 Answers3

29

The property you’re looking for is on; in method form, -setOn: or -setOn:animated:.

selected is a generic property, declared on UIControl, which has no visible effect on a UISwitch.

Noah Witherspoon
  • 57,021
  • 16
  • 130
  • 131
3

Would be something like this

[mailswitch setOn:YES animated:YES];
user3167213
  • 215
  • 1
  • 9
2

setOn should work

When I developed an iPhone App, I had problems with checking the status of a checkbox, too. My workaround was to call a function everytime this checkbos is selected or deselected, and save the status then in another variable.