我的 View
中有一个NSTableview
,当用户选择特定的行
时,我想执行一些其他操作。我尝试了 tableViewSelectionDidChange
方法,但它似乎不起作用。
-(void)tableViewSelectionDidChange:(NSNotification *)notification
{
NSInteger row = [self.InfoTable selectedRow];
if (row == -1) {
return;
}else{
self.NumberInputTextField.stringValue = studentsInTable[row][0];
self.NameInputTextField.stringValue = studentsInTable[row][1];
self.ClassnumberInputTextField.stringValue = studentsInTable[row][1];
}
}
我有
@interface ViewController : NSViewController <NSTableViewDelegate,NSTableViewDataSource>
和
self.InfoTable.dataSource = self;
self.InfoTable.dataSource = self;
另外,我用谷歌搜索过,但没有找到有用的答案。 谁能给我一点提示吗?
最佳答案
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
是委托(delegate)方法,但您仅将 dataSource 设置为 self。
[self.InfoTable setDelegate:self];
关于objective-c - cocoa-如何使用tableViewSelectionDidChange :?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34389155/