DavydLiu / DLRadioButton

Radio Button for iOS
MIT License
948 stars 202 forks source link

Single radio button selection for tableView #123

Open ikyh opened 6 years ago

ikyh commented 6 years ago

Hi.! Nice Library. I have an expandable tableView. When I click on tableView header the cell expands. My headerView is custom uiview designed using xib. It has a DLRadioButton and a label. There is only one DLRadioButton in each headerViewCell. I want to select only one radio button at a time i.e single selection. Right now it is selecting the radio button for each cell. How can I make single selection of DLRadioButton in tableview.

Also initially the icon color should be black. When the user selects the radio button then both the icon and indicator color should turn green. Please help me solve this issue.

DavydLiu commented 6 years ago

Thx, you can add radio buttons in each cell, and group them in an array. Finally, set the otherButtons property.

ikyh commented 6 years ago

@DavydLiu How am I supposed to add buttons in each cell when tableView renders dynamic data. I have just a single DLRadioButton in custom tableViewCell xib, and I have to select only one user at a time from tableView.

DavydLiu commented 6 years ago

You can have the table view controller reference to the radio button group and return individual button in the table view data source

shadyk commented 6 years ago

@DavydLiu can u add an example for this

tushar40 commented 3 years ago

@DavydLiu I am having the same problem and i do not want to reference the buttons as UITableView reuses the cells (which contains DLRadioButton in my case), so is there a way to show their selected and deselected state by only changing "button.isSelected" property from "didSelectRowAt". I want to select multiple tableViewCells at the same time.

Your help will be greatly appreciated.