Solution for moving text fields out of the way of the keyboard in iOS
What is TPKeyboardAvoiding?
There are a hundred and one proposed solutions out there for how to move UITextField and UITextView out of the way of the keyboard during editing — usually, it comes down to observing UIKeyboardWillShowNotification and UIKeyboardWillHideNotification, or implementing UITextFieldDelegate delegate methods, and adjusting the frame of the superview, or using UITableView’s scrollToRowAtIndexPath:atScrollPosition:animated:, but most proposed solutions tend to be quite DIY, and have to be implemented for each view controller that needs it.
This is a relatively universal, drop-in solution: UIScrollView and UITableView subclasses that handle everything.
When the keyboard is about to appear, the subclass will find the subview that’s about to be edited, and adjust its frame and content offset to make sure that view is visible, with an animation to match the keyboard pop-up. When the keyboard disappears, it restores its prior size.
It should work with basically any setup, either a UITableView-based interface, or one consisting of views placed manually.
It also automatically hooks up “Next” buttons on the keyboard to switch through the text fields.
Overview
- Pricing: Free
- Resource Link: https://github.com/michaeltyson/TPKeyboardAvoiding
- Resource Maker: Michael Tyson
- Mobile Platform Destination: iOS Apps
- Mobile Platform Support: Native iOS
- Programming Languages: Objective-C
Related resources
MakemojiSDK
Emoji Keyboard SDK
PhotoEditor
A Photo Editor library with simple, easy support for image editing
PasswordTextField
A custom TextField with a switchable icon which shows or hides the password