UISwitch setSelected not working?

I am trying to set the selected value to UISwitch and it is not responding!

Here is my code

I set the value for UISwitch. The default value is False.

[mailSwitch setSelected:TRUE]; 

Can someone help me.

+8
objective-c uiswitch
source share
3 answers

The property you are looking for is on ; in the form of the -setOn: or -setOn:animated: method.

selected is a common property declared in UIControl that has no visible effect on UISwitch.

+24
source share

There will be something like this

 [mailswitch setOn:YES animated:YES]; 
+2
source share

setOn should work

When I developed the application for the iPhone, I had problems checking the status of the checkbox. My workaround was to call the function every time that checkbos is selected or canceled, and save the status, and then in another variable.

+1
source share

All Articles