在按键时而不是返回时从NSTextField发送操作

3 cocoa nstextfield ibaction

我想在解除密钥后显示新推文留下的字符数.目前,只有在取消回报时才会发生这种情况:

- (IBAction)updateCharacterCountFromNewTweetField:(id)sender {
  [newTweetCharacterCount setIntValue:140 - [[sender stringValue] length]];
}
Run Code Online (Sandbox Code Playgroud)

此操作连接到NSTextField(NOT A UITextField !!): 替代文字

这对用户来说很糟糕,因为他们希望立即看到字符数,而不仅仅是在按下返回之后.

谁能帮我吗?谢谢.

Nat*_*ger 5

在文本字段上设置委托,并让它实现controlTextDidChange: delegate方法.

另请参见文本编辑编程指南:委派消息和通知.