Introduction -
First, we need to know what exactly “InputAccessoryView” is, it is basically mentioned in the Apple developer documentation, so we know about the InputAccessoryView it is a custom view that occurred at the top of the system keyboard when any receiver becomes the first responder.
You can check this in the image below.
InputAccessoryView redeclares anything which he inherits from UIResponder because it is based on UIResponder and InputAccessoryView has the property of reading and write and also manages a custom view.
Responder infrastructure first mounts the view then keeps it in sync with the system keyboard. Some of the gestures are applied to the InputAccessoryView that gestures are like tap, drag, etc which use to dismiss the keyboard.
Use Cases -
There are two main use cases of InputAccessoryView.
- You can create a view like Facebook composer view picker
- You can also design a toolbar
- The second scenario is sticky text inputs:
Objective-C UIResponder -
There are separate view designs for objective c and <TextInput> has become a responder for an instance of UITextView or UITextField.
API Designs -
I think now we can understand the <InputAccessoryView>, and how to use it as well, so now we are going to design the API for both the cases.and it works well with react-native components.
First, we check it for the keyboard toolbar, there are the following things for consideration.
- <InputAccessoryView> we want to hoist generic react-native hierarchy.
- It is also used for manipulating the application state and it detaches the view hierarchy.
- Particular <TextInput> is also linked to <InputAccessoryView>
- We can also share the multiple text inputs without duplicating the code
Second, for sticky notes, the following are some points.
- For sticky note support, it adds some more constraints.
- For the design purpose, the input accessory has a text input as a child view.
- We can manually set the generic view.
Some Pitfalls -
Continue Reading: InputAccessoryView