【发布时间】:2016-08-10 10:03:22
【问题描述】:
我已按照 RadioButton 的 this 教程进行操作。我已将它与 tableview 集成。问题是当我选择表格行时,单选按钮没有被选中。只有当我点击 RadioButton 时它才会被选中。我希望在选择表格行时选择单选按钮。代码如下:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
RadioButton *rb1 = [[RadioButton alloc] initWithGroupId:@"Group" index:indexPath.row];
rb1.frame = CGRectMake(20,13,22,22);
[cell.contentView addSubview:rb1];
cell.textLabel.text = @"ABC";
return cell;
}
【问题讨论】:
-
把你的选择代码放在 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { }
标签: ios radio-button tableview selection