我在区分两个 NSTableView 时遇到问题,需要一些帮助。
我尝试过这些方法:
1.
- (void)tableViewSelectionDidChange:(NSNotification *)notification {
if ([[notification object] tag] == 0) {
NSInteger row = [self.categoryTableView selectedRow];
...do stuff
} else {
if ([[notification object] tag] == 1 ) {
[self showItemSheet:self];
}
}
}
和2:
- (void)tableViewSelectionDidChange:(NSNotification *)notification {
if ([notification object] == categoryTableView) {
NSInteger row = [self.categoryTableView selectedRow];
..do stuff
} else {
if ([notification object] == itemTable ) {
[self showItemSheet:self];
}
}
}
这两种方法在大多数情况下都有效。但是,如果我继续从带有标签 0 的表格 View 中进行选择,则每点击三到四次,我就会看到启动的 itemSheet 表。
最佳答案
您可以尝试使用委托(delegate)方法而不是通知来实现您想要的吗?从上面的代码来看,一切看起来都很好,所以错误可能在其他地方?
关于cocoa - 如何区分同一窗口中的两个 nstableview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23304063/