开发者

can anyone tell me how to use switch? [duplicate]

This question already has an answer here: Closed 11 years ago.

Possible Duplicate:

How to apply setting by toggle switch?

I want to use switch but开发者_如何学运维ton to toggle on and off of a setting

can anyone tell me how to set it up? I already have the following code

Thanks!

declaration

- (IBAction) changeMode:(id)sender;

implementation

-(IBAction) changeMode:(id)sender
{
}


After you hook up the UISwitch in Interface Builder, you can check if it's on like this:

-(IBAction) changeMode:(id)sender
{
     if ([(UISwitch *)sender on])
     {
          NSLog(@"The switch is on.");
     }
     else
     {
          NSLog(@"The switch is off.");
     }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜