UITextFieldDelegate vs UITextField control events

后端 未结 5 806
隐瞒了意图╮
隐瞒了意图╮ 2021-02-14 08:17

If I want to handle changes to a UITextField, such as the user typing in it; it seems like this can be done either by assigning a delegate to that text field, and then having th

5条回答
  •  -上瘾入骨i
    2021-02-14 09:10

    I have found out that shouldChangeCharactersInRange passes the same NSRange for insertion and deletion of text. You append a space and then delete it, and the parameters from shouldChangeCharactersInRange are indistinguishable from duplication of the text.

    So shouldChangeCharactersInRange actually cannot predict the resulting text.

提交回复
热议问题