【发布时间】:2018-08-05 14:05:32
【问题描述】:
在 UITableView 中加载动态数据。我有 2 个 RadioButtons(groupButtons) 和 btnPaul 和 btnAdam 标题 Paul 和 Adam 在 UITableView 和一个 label(lblCheckStatus)。如果[cell.btnPaul setSelected:YES]; btnPaul.titlelebel.text 应该分配给标签,即保罗,如果[cell.btnPaul setSelected:NO]; 标签应该在UITableView 中为空。我已经尝试过以下代码,但无法获得正确的响应以获取空值。 TIA
// cellForRowAtIndexPath:
NSMutableDictionary* respDict = [respnseArray objectAtIndex:indexPath.row];
NSString *str = [respDict objectForKey:@"Name"];
if ([str isEqualToString:@"Paul"]) {
[cell.btnPaul setSelected:YES];
} else {
[cell.btnAdam setSelected:YES];
}
cell.btnPaul.tag = +indexPath.row;
[cell.btnPaul addTarget:self action:@selector(btnCheckClicked:) forControlEvents:UIControlEventTouchUpInside];
cell.btnPaul.tag = +indexPath.row;
[cell.btnPaul addTarget:self action:@selector(btnCheckClicked:) forControlEvents:UIControlEventTouchUpInside];
// RadioButton Checked
- (IBAction)btnCheckClicked:(RadioButton *)sender {
UIButton *btn = (UIButton *)sender;
NSUInteger tag = btn.tag;
static NSString *CellIdentifier = @"Cell";
FriendsCell *cell = (FriendsCell *) [_btlFriends dequeueReusableCellWithIdentifier:CellIdentifier];
cell.lblCheckStatus.text = sender.titleLabel.text;
NSLog(@"%@",cell.lblCheckStatus.text);
}
【问题讨论】:
-
为什么添加
= +indexPath.row;
标签: ios objective-c uitableview xcode9