Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISwitch setSelected not working?

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.

like image 627
HardCode Avatar asked Oct 19 '11 16:10

HardCode


2 Answers

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.

like image 73
Noah Witherspoon Avatar answered Oct 19 '22 03:10

Noah Witherspoon


Would be something like this

[mailswitch setOn:YES animated:YES];
like image 38
user3167213 Avatar answered Oct 19 '22 02:10

user3167213