我想使用开关按钮来打开和关闭设置
谁能告诉我如何设置它?我已经有以下代码
谢谢!
声明
- (IBAction) changeMode:(id)sender;
实施
-(IBAction) changeMode:(id)sender
{
}
答案 0 :(得分:3)
在Interface Builder中连接UISwitch后,您可以检查它是否打开:
-(IBAction) changeMode:(id)sender
{
if ([(UISwitch *)sender on])
{
NSLog(@"The switch is on.");
}
else
{
NSLog(@"The switch is off.");
}
}