我已经阅读了有关 UISwitches 的所有内容,但在我的情况下似乎无法弄清楚它们。我有 2 个 UISwitches。为了让我的代码正常工作,只有其中一个可以打开。我将如何做到这一点?
到目前为止,我已经尝试...
我的类.h
-(IBAction)sufSwitchChanged:(id)sender;
我的班级.m
-(IBAction)preSwitchChanged:(id)sender {
UISwitch *whichSwitch = (UISwitch *)sender;
BOOL setting = whichSwitch.isOn;
[newsPre setOn:setting animated:YES];
[techPre setOn:setting animated:YES];
}
....这有效,但它使两个开关都打开或关闭。我只需要弄清楚如何防止它们同时开启。