【发布时间】:2014-02-12 11:48:03
【问题描述】:
我在更新 UITableView 中的行时遇到问题。在我的tableView 中只能选择一节中的一行(可以有几个节)。因此,当用户选择行时,我以编程方式取消选择本节中的其他行。当取消选择的行可见时,一切正常。如果任何取消选择的行不可见,则仍会对其进行检查。但是此行调用了didDeselectRowAtIndexPath。为什么?如何解决这个问题?
- (NSIndexPath*)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
// It is predefined group - only one row in section cab be selected
// Deselect other rows in section
for (NSIndexPath * selectedIndexPath in tagTableView.indexPathsForSelectedRows) {
if (selectedIndexPath.section == indexPath.section) {
[self tableView:tableView didDeselectRowAtIndexPath:selectedIndexPath];
[tableView deselectRowAtIndexPath:selectedIndexPath animated:YES];
}
}
return indexPath;
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tagTableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone;
}
【问题讨论】:
标签: ios uitableview selection