Reputation: 1729
This may seem very silly, maybe i am not understanding it correctly.
I have a UISwitch in my scene.
when a login button is clicked
if the switch is on - do some thing
if the switch is off - do something else
when i first add the switch and run the app i can switch it on and off but if i then add an outlet to my viewcontroller.h the switch is then greyed out. (most likely because it wants me to write my own animation and action???)
From my understanding for this i shouldnt need to create an action for it i just want to simply no if the switch is on or off.
Is this possible or do i need an action for it?
Upvotes: 1
Views: 56
Reputation: 121
No need to write any animation related code just follow below step and you can achieve what you want.
@interface FirstTabViewController : UIViewController { __weak IBOutlet UISwitch *switchLogin; } -(IBAction)btnLoginClicked:(id)sender;
-(IBAction)btnLoginClicked:(id)sender { if (switchLogin.on) { //switch is on do whatever you want NSLog(@"switch is on do whatever you want"); } else { // NSLog(@"switch is off do whatever you want"); } }
Upvotes: 1