所以这是我不是很优雅的解决方案-
NSArray* _radioButtonsArray;
在viewDIdLoad中初始化它:
_radioButtonsArray = [[NSArray alloc] initWithObjects:_radioButton1,_radioButton2,_radioButton3, nil];
定义一个radioButtonIsPressed方法并将其作为操作连接到所有单选按钮:
-(IBAction)radioButtonIsPressed:(id)sender{ for (NSButton* btn in _radioButtonsArray){ if (btn != sender) [btn setState:0]; } }
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句