Search code examples
ioscarettextinput

iOS text input issue: the caret flies in


When I type in words, the caret of the textfield flies in.

And I noticed that , this situation only occurs the the first time. I think it is a init issue,

bug

If I assign a frame to the caret at first, may be OK.

And i saw the issue on Ever Notes ,too. enter image description here

I think , caretRect(for:) method of UITextInput is related.

How to solve it? Any good ideas?


Solution

  • Because of this question I noticed the same thing happening in my app, and a quick & hacky way to get rid of the animation was to put these two lines in my viewWillAppear:

    self.searchBar.becomeFirstResponder()
    self.searchBar.resignFirstResponder()