check this tutorial from Apple documentations
https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html
Look for
Moving Content That Is Located Under the Keyboard