0

我正在使用 GSRadioButtonSetController 实现单选按钮...我创建了两个按钮并包含在 IBOutletCollection(UIButton) NSArray *buttonCollection....然后我将 GSRadioButtonSetController.h 和 GSRadioButtonSetController.m 文件包含到我的项目中。然后在我的 viewdidload 中添加

// Instantiate your GSRadioButtonSetController object
self.radioButtonSetController = [[GSRadioButtonSetController alloc] init];

// Set its delegate to your view controller
self.radioButtonSetController.delegate = self;

// Set its buttons property to an array of buttons that you've
// created previously.
self.radioButtonSetController.buttons = buttonCollection;

然后我把

- (void)radioButtonSetController:(GSRadioButtonSetController *)controller
      didSelectButtonAtIndex:(NSUInteger)selectedIndex
{

//implemetation


 }

按钮有两个图像...一个用于选择状态,第二个用于 deselcetd 状态....代码给了我索引但是我不知道如何动态更改为图像以便用户知道选择了哪个和哪个不是...

提前感谢

4

1 回答 1

0

当您创建要添加到 `buttonCollection' 的按钮时,将图像设置为按钮,例如:

[button_1 setImage:[UIImage imageNamed:@"radio_button_off.png"] forState:UIControlStateNormal];
[button_1 setImage:[UIImage imageNamed:@"radio_button_on.png"] forState:UIControlStateSelected];

它对我有用

于 2013-03-22T12:45:13.703 回答