What I want?
I want to add radio button functionality where a user in particular section can only select one row
How am I doing it?
I added UISwitch
and based on what row user click I would like to do the following
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 1 || indexPath.section == 2) {
// disable all the rows of this section except indexPath.row
}
}
Where am I stuck?
How do I get all the rows for a given section in UITableView
?
P.S: I am a week old to iOS
and learning, so bear with me if this is a stupid question
Use[tableView cellForRowAtIndexPath:(NSIndexPath *)]
for (int i = 0; i < [self.tableView numberOfRowsInSection:indexPath.section]; i++) {
if (i != indexPath.row) {
UITableViewCell* cell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:indexPath.section]];
//Do your stuff
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With