让google搜索nstableview edit change,你会得到很多详细的答案。
简而言之:使用(某些)以下(和类似的)委托方法:
- (void)controlTextDidEndEditing:(NSNotification *)obj
- (void)controlTextDidChange:(NSNotification *)aNotification
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
并测试它们以显示适合您的应用程序的内容:
- (void)controlTextDidEndEditing:(NSNotification *)obj
{
NSDictionary *userInfo = [obj userInfo];
NSTextView *aView = [userInfo valueForKey:@"NSFieldEditor"];
NSLog(@"controlTextDidEndEditing %@", [aView string] );
}
- (void)controlTextDidChange:(NSNotification *)aNotification
{
NSDictionary *userInfo = [aNotification userInfo];
NSTextView *aView = [userInfo valueForKey:@"NSFieldEditor"];
NSLog(@"controlTextDidChange >>%@<<", [aView string] );
}
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
{
NSLog(@"control: textShouldEndEditing >%@<", [fieldEditor string] );
return YES;
}
您可以这样做,因为 s; 的单元格NSTableView
是NSTextFieldCell
s;