Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animating UITextInput's textInputView

UIKit text input components, such as UITextView and UITextField have a property inputView to add a custom keyboard. There are two questions I have relating to this.

  1. If the keyboard is currently visible and the property is set to a new input view, nothing happens. Resigning and regaining first responder status refreshes the input and displays the new view. Is this the best way to do it? If so it might answer my bigger question:

  2. Is it possible to animate the transition between two input views?

like image 735
Anthony Mattox Avatar asked Feb 07 '13 16:02

Anthony Mattox


People also ask

How do you make your react native app respond gracefully when the keyboard pops up?

If you're on Android you'll want to use keyboardDidShow and keyboardDidHide instead. When the keyboardWillShow event is emitted you'll set an animated variable to the final height of the keyboard and have it animate for the same duration as the keyboard sliding animation.

How do you auto scroll the screen up when virtual keyboard appears in react native?

You can use ScrollView to control screen up and down movements. As long as user hasn't focused any TextInput , you can disable scroll. On focus, just shift up the scrollview using Content Offset prop. Hope it helps!

What is TextInput in react?

TextInput is a Core Component that allows the user to enter text. It has an onChangeText prop that takes a function to be called every time the text changed, and an onSubmitEditing prop that takes a function to be called when the text is submitted.

How do I stop collapsing screen when keyboard opens in react native?

You can use KeyboardAwareScrollView .


1 Answers

From the UIResponder docs:

Responder objects that require a custom view to gather input from the user should redeclare this property as readwrite and use it to manage their custom input view. When the receiver subsequently becomes the first responder, the responder infrastructure presents the specified input view automatically. Similarly, when the view resigns its first responder status, the responder infrastructure automatically dismisses the specified view.

So unfortunately the answer to 1 is Yes and 2 is No.

like image 85
Rikkles Avatar answered Oct 03 '22 09:10

Rikkles