【发布时间】:2013-09-23 15:18:51
【问题描述】:
我有两个表视图来控制对象集合的显示/排序(即按类别和本地化,即 Lieu)。 我的问题是:我希望在用户单击任何这些表视图中的单元格时更新选择(使用 NSTableViewDelegate 可以正常工作),但我也想将选择恢复为另一个表中的默认值查看。
我的问题很明显:每次调用 tableViewSelectionDidChange 都会触发对自己的另一个调用,这使得结果非常不稳定。有没有办法阻止这个电话[tableViewCategory selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO]; 触发通知?
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
{
if ([[[aNotification object]identifier]isEqualToString:@"table2"]){
//First, reset AnnonceWithCategory
[tableViewCategory selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO];
//Then
[self showAnnoncesWithLieu];
}
else if ([[[aNotification object]identifier]isEqualToString:@"table3"]){
//First, reset AnnonceWithLieu
[tableViewLieu selectRowIndexes:[NSIndexSet indexSetWithIndex:0] byExtendingSelection:NO];
[self showAnnoncesWithCategory];
}
}
【问题讨论】:
标签: objective-c cocoa nstableview