Reputation: 11757
I need to copy google hangouts keyboard. Right now I'm using a custom view as inputAccessoryView
. Using inputAccessoryView
lets me hide the keyboard interactively
(option to be set in the TableViewController from the IB), so the keyboard is hidden while the user swipes it down.
They keyboard let's you choose if you want to send text or an image from gallery or take a pic... When you tap the "Image Gallery button", the keyboard hides and shows the images that are in the gallery in the space the keyboard was. This is my problem, I have no idea how to hide the keyboard but keep showing the "inputAccessoryView" at the exact same position... Also where should I put the view that shows the images? Because if I include all that in the "inputAccessoryView" custom view, that's going to be shown all the time, because it's going to be included in the xib of my custom view...
Here is a gif with how the keyboard behaves:
Any clue?
Upvotes: 0
Views: 192
Reputation: 8006
You can use the inputView
property of text field.
The custom input view to display when the text field becomes the first responder.
@property(readwrite, strong) UIView *inputView
If the value in this property is nil, the text field displays the standard system keyboard when it becomes first responder. Assigning a custom view to this property causes that view to be presented instead.
The default value of this property is nil.
It basically let's you use any view as an input view.
You can "hot swap" this like that :
[textField resignFirstResponder];
textField.inputView = yourCustomView
[textField becomeFirstResponder];
The inputAccessoryView
will stay in place (assuming that your views frame matches that of keyboard). I can't seem to figure out the animation of the hiding keyboard, this may be somewhat tricky. A bit hackish way would be to take a screenshot of the keyboard, add it as a view and animate it.
Upvotes: 1