我想显示解除按键后新推文剩余的字符数。目前,只有在取消退货时才会发生这种情况:
- (IBAction)updateCharacterCountFromNewTweetField:(id)sender {
[newTweetCharacterCount setIntValue:140 - [[sender stringValue] length]];
}
This action is connected to an NSTextField (NOT A UITextField!!):
这对用户来说很糟糕,因为他们希望立即看到字符数,而不是在按回车键后才看到。
谁能帮我吗?谢谢。
在文本字段上设置委托并让它实现controlTextDidChange: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSControl_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/controlTextDidChange:委托方法。
也可以看看文本编辑编程指南:委托消息和通知 http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/TextEditing/Tasks/DelegatesAndNotif.html.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)