简体   繁体   English

按下检测删除键

[英]Detect delete key was pressed

I'm writing a function that formats the entries on a UITextField to a date. 我正在编写一个函数,将UITextField上的条目格式化为日期。 It must be displayed like this dd/mm/yyyy. 它必须显示为dd / mm / yyyy。 The problem is that I'm not being able to detect the delete key was pressed. 问题是我无法检测到按下了删除键。 I'm using UITextFieldDelegate method textField:shouldChangeCharactersInRange:replacementString: to detect when the user presses a key. 我正在使用UITextFieldDelegate方法textField:shouldChangeCharactersInRange:replacementString:来检测用户何时按下某个键。 Is there something like a \\n I may look for on the replacementString ? 是否有像\\n我可以在replacementString

当要删除字符时,替换字符串应为空字符串( @"" )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM