UISwitch Class: Provides a method to control on and off state in your application. For example if you wanted to receive a alert when your application receive any updates you can set it to on, if your application got the switch feature.
UISwitch Class: Provides a method to control on and off state in your application. For example if you wanted to receive a alert when your application receive any updates you can set it to on, if your application got the switch feature.UISwitch Class: Provides a method to control on and off state in your application. For example if you wanted to receive a alert when your application receive any updates you can set it to on, if your application got the switch feature.
In the example we will discuss about the same feature "UISwitch" control and will connect it to a action that will send a action message.
a simple example: UISwitch Action
-(IBAction)switchingbtn:(id)sender { } |
This is a simple action that will be further connected to UISwitch in .sib file. The action will recognize the status of switch control and returns a corresponding message.
You can create you UISwitch either programmatically or simply drag and drop a UISwitch control in the .Xib (nib file). We used the .sib as it's easy and fast. If you are using .sib then declare the UISwitch in header file as given below…
#import <UIKit/UIKit.h> @interface SwitchActionViewController : UIViewController { UISwitch* switchControll; @property(nonatomic, retain)IBOutlet UISwitch* switchControll; @end and synthesize the switchControll.. see the code below.. @implementation SwitchActionViewController - (void)dealloc { // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. -(IBAction)switchingbtn:(id)sender { - (void)viewDidUnload { @end |
The output is: