Should beFirstResponder () always be called in the main thread?

Should beFirstResponder () always be called in the main thread?

DispatchQueue.main.async {
         self.inputBarView.placeholderTextView.becomeFirstResponder()
}

I fixed the flickering problem and the animation became smoother after I made sure the method was called in the main thread.

However, I am not sure what is right.

0
source share
1 answer

Which may make your animation smoother is not the fact that you are calling becomeFirstResponderin the main thread, but probably because the animation that starts when your placeholderTextViewfirst responder is executed in the main thread.

Instead of calling becomeFirstResponderin your main thread, you should make sure that all animations and user interface updates are done in the main thread, and not in the functions that cause these changes.

0

Source: https://habr.com/ru/post/1687881/


All Articles