开发者

How to detect ios numberpad delete press

开发者 https://www.devze.com 2023-03-02 05:21 出处:网络
dose anyone know how to detect a delete pre开发者_Go百科ss from a numberpad in ios?If you\'re using a UITextField, your delegate\'s textField:shouldChangeCharactersInRange:replacementString: will be c

dose anyone know how to detect a delete pre开发者_Go百科ss from a numberpad in ios?


If you're using a UITextField, your delegate's textField:shouldChangeCharactersInRange:replacementString: will be called with a range of length 1 and an empty replacement string. If nothing is deleted, however, you will get no notification.

If you're using a UITextView, your delegate's textView:shouldChangeTextInRange:replacementText: will be called with a range of length 1 and an empty replacement string. If nothing is deleted, however, you will get no notification.

If you're using your own class that implements UIKeyInput, deleteBackward is supposed to be called. I don't know whether a class implementing UITextInput (which itself includes UIKeyInput) might ever have replaceRange:withText: or setMarkedText:selectedRange: called instead with a range of length 1 and an empty replacement string, or what might happen in those cases if there is nothing to delete.


If you are implementing something like a passcode, I think a hidden textfield would be preferable, and more controls.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号