_ 其实只是数据源的变化。 UI跟着变就好了
“` //选择实现单选
-(void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath
{
NSMutableDictionary *dic=_arrData[indexPath.row];
if ([dic[@"select"] isEqualToString:@"YES"])
{
//如果已经选择,就取消选择,
[dic setValue:@"NO" forKey:@"select"];
}
else
{
[dic setValue:@"YES" forKey:@"select"];
}
//把团来选中的都改为没选中
for (int i=0;i<_arrData.count;i++)
{
if (i==indexPath.row)//如果是当前选择的行就不做修改
{
continue;
}
NSMutableDictionary *dic1=_arrData[i];
[dic1 setValue:@"NO" forKey:@"select"];
[_arrData replaceObjectAtIndex:i withObject:dic1];
}
//将当前选中的单元格的数据替换修改后的数据
[_arrData replaceObjectAtIndex:indexPath.row withObject:dic];
//刷新表格
[tableView reloadData];
}
/**
在cell内部赋值操作
* 设置cell内容的方法
*
* @param dic 内容字典
*/
-(void)setCell:(NSDictionary *)dic
{
_imgHead.image=dic[@"imgHead"];
_lblNickname.text=dic[@"nickname"];
_lblDescribe.text=dic[@"describe"];
_imgChoose.image=[UIImage imageNamed:@"boss_unipay_ic_right@2x.png"];
//如果选择是YES就显示打勾图片,否则就隐藏
if ([dic[@"select"] isEqualToString:@"YES"])
{
_imgChoose.hidden=NO;
}
else
{
_imgChoose.hidden=YES;
}
} “`