onegray / RadioButton-ios

Lightweight RadioButton class for iOS
MIT License
377 stars 68 forks source link

Selection bug! #1

Closed jugsvn closed 10 years ago

jugsvn commented 10 years ago

Hey there seems like a bug in the

-(void) setSelected:(BOOL)selected method.

Instead of [rb super_setSelected:selected]; it should rather be [rb super_setSelected:NO];

onegray commented 10 years ago

Hm.. The idea is to automatically select another button when you deselect the current one.

jugsvn commented 10 years ago

Agreed. But when you try to deselect all the buttons (when the screen loads or after data refresh), it will always select the first button by default.

So

[self.options[0] setSelected:NO]; [self.options[1] setSelected:NO]; [self.options[2] setSelected:NO]; [self.options[3] setSelected:NO];

will result in the first button being selected.

onegray commented 10 years ago

I've just added method 'deselectAllButtons' for this case. Anyway, I agree the 'setSelected:NO' functionality is ambiguous if there are more then two buttons in the group.

onegray commented 10 years ago

I've updated the 'setSelected:' method. Now the logic is following: If selected==YES, then it selects the button and deselects other buttons in the group. If selected==NO, then it deselects the button and if there are only two buttons in the group, then it selects second.

Thank you for the participation!

jugsvn commented 10 years ago

Awesome! Thanks mate!