【问题标题】:can anyone tell me how to use switch? [duplicate]谁能告诉我如何使用开关? [复制]
【发布时间】:2011-04-12 17:40:02
【问题描述】:

可能重复:
How to apply setting by toggle switch?

我想使用开关按钮来打开和关闭设置

谁能告诉我如何设置它?我已经有以下代码

谢谢!

声明

- (IBAction) changeMode:(id)sender;

实现

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

【问题讨论】:

  • 您在 2 小时前问过这个问题并得到了答案!请不要重复提问。 stackoverflow.com/questions/5637799/…
  • 我不同意我得到了答案,我还是不明白,现在我明白了
  • 那除了发一个重复的问题,还有其他事情要做,第一个是be 耐心,因为这里的人是自愿帮助你的.两个小时不是很长的时间。此处列出了更多选项:stackoverflow.com/faq#bounty
  • +1 表示“耐心”和“不要重复发布”。为不良行为找借口对你没有帮助。

标签: cocoa-touch ios button switch-statement


【解决方案1】:

在 Interface Builder 中连接 UISwitch 后,您可以像这样检查它是否打开:

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

【讨论】:

    猜你喜欢
    • 2020-11-14
    • 2021-09-07
    • 1970-01-01
    • 2018-01-21
    • 1970-01-01
    • 2015-03-22
    • 1970-01-01
    • 2014-08-14
    • 2014-11-10
    相关资源
    最近更新 更多