How shouldChangeCharactersInRange works in Swift?

前端 未结 7 706
不思量自难忘°
不思量自难忘° 2020-12-07 17:38

I\'m using shouldChangeCharactersInRange as a way of using on-the-fly type search.

However I\'m having a problem, shouldChangeCharactersInRange get

7条回答
  •  情书的邮戳
    2020-12-07 17:48

    This function is called when changes are made but UI is not updated and waiting for your choice

    Take a look at returned bool value

    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool
    
    • If you return true - it means that iOS accept changes(text, caret...)
    • If you return false - it means that you are responsible for all this stuff

提交回复
热议问题