【发布时间】:2013-01-26 06:34:23
【问题描述】:
我有一个应用程序,当用户选择新单元格时,我需要在其中取消选择选定的单元格。我可以选择和取消选择 tableview 行,但问题是我一次只需要选择一行。我现在就是这样,
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.backgroundColor =[UIColor colorWithPatternImage:[UIImage imageNamed:@"white_cell_check.png"]];
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.backgroundColor =[UIColor colorWithPatternImage:[UIImage imageNamed:@"white_cell.png"]];
}
但在此我可以选择和取消选择同一行。但我的意图是在选择新行时,如果已经选择了任何其他单元格,则需要取消选择。任何人都可以帮助我吗?
【问题讨论】: