谁能告诉我如何使用交换机? [英] can anyone tell me how to use switch?
本文介绍了谁能告诉我如何使用交换机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
如何通过拨动开关申请设置?
块引用>我想用开关按钮来打开和关闭的设置的
谁能告诉我如何设置?我已经有以下code
谢谢!
声明
- (IBAction为)changeMode:(ID)发送;
实施
- (IBAction为)changeMode:(ID)发送者
{
}
解决方案您挂接在Interface Builder中UISwitch后,您可以检查它是否在这样的:
- (IBAction为)changeMode:(ID)发送者
{
如果([上(UISwitch *)发件人])
{
的NSLog(@的开关已打开。);
}
其他
{
的NSLog(@的开关已关闭。);
}
}Possible Duplicate:
How to apply setting by toggle switch?I want to use switch button 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."); } }
这篇关于谁能告诉我如何使用交换机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文