I'm new to iOS development and have recently learned that to make the on screen keyboard disappear we must always call resignFirstResponder on the text view. This causes the text view to relinquish it's first responder status, and hence the keyboard disappears, since there is no need for the text view to respond.
However I also noticed that there's the becomeFirstResponder method to make a view a first responder. However, this method is never called on the text view. So when/how does a textview become first responder when that method is never called?(at least, by me. I'm unsure if it is called elsewhere in the system)
My theory is that is has to already be a first responder before it can resign the first responder status.
textViewDidBeginEditiing
or more broadly by listening for keyboard notifications (UIKeyboardWillShowNotification
for example) – Louis TurresignFirstResponder
(such as callingendEditing:
on a container view, or setting a scroll view'sUIScrollViewKeyboardDismissMode
). In the simulator, it's possible that the keyboard doesn't show up still, and in that case you just want to make sure keyboard hardware is toggled (Cmd+K) – Louis Tur