Writing plenty of codes to move UIResponder subclasses to move up when keyboard is presented is outdated and cumbersome. Also, it does not look good while reviewing the codes.
This tutorial will guide you through a very easy process to achieve this and that through storyboard so this is an add on. Just by implementing some easy steps we would be able to move the UITextFields and even UIViews above the keyboard. The best part of this is that we don’t need to do anything special for various devices.
So let’ s start :
1. We need to download a small library of some classes from the following link. It is TPKeyboardAvoiding.
2. Just drag and drop the entire folder named “TPKeyboardAvoiding” to your project.
3. Before you start designing your screen, add a UIScrollView initially and then start with your designing.
Refer to this tutorial for working with scroll views and auto layout: Scroll View and Auto Layout .
4. Select the UIScrollView and then subclass it for “TPKeyboardAvoidingScrollView” from storyboard itself.
5. GO AHEAD! with design development. We are almost done.
6. Before we RUN the application we need to import one file in the .pch file :
#import "TPKeyboardAvoidingScrollView.h"
Refer to the tutorial to see how to add a .pch file in the project: How to add a .pch file to your project.
7. Now, we are all set to RUN the application on any device and for any iOS Version.
Hope you will not find any difficulty implementing TPKeyboardAvoid.
Feel free to post your suggestions and your contribution to improving this tutorial will be highly appreciated .
Thanks for visiting and do help your friends to save their time.