Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道为什么我无法找到有关键盘 keyup/keydown 事件的任何帮助,我实际上想检测用户在输入 UITextField 中的文本时通过 iphone 上的键盘按下了哪个键。
您可以使用此委托方法来获取输入到 UITextField 中的字符:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;
例如:
if ([string isEqualToString:@"z"]){ // z is being typed. }
只需确保您已将 UITextField 的委托指定给您实现它的类文件。