explaingit

michaeltyson/tpkeyboardavoiding

5,799Objective-CAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

A drop-in iOS library that automatically scrolls text fields into view when the on-screen keyboard appears, preventing them from being hidden during typing.

Mindmap

mindmap
  root((TPKeyboardAvoiding))
    What it does
      Keyboard avoidance
      Auto scroll
      Next key wiring
    How it works
      Scroll view class
      Table view class
      Animation match
    Tech
      Objective-C
      iOS UIKit
    Use cases
      Login forms
      Sign up screens
      Table forms
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add automatic keyboard-avoidance to an iOS form screen without writing any custom scroll-management code.

USE CASE 2

Enable the keyboard Next button to jump between text fields in order automatically throughout an app.

USE CASE 3

Apply keyboard avoidance to a table view by swapping in one custom class with no other changes.

USE CASE 4

Prevent text fields from being hidden by the keyboard on a login or sign-up screen without custom UIScrollView logic.

Tech stack

Objective-CiOS

Getting it running

Difficulty · easy Time to first run · 5min
Use freely in personal or commercial apps with minimal restrictions, keep the copyright notice in your documentation.

In plain English

TPKeyboardAvoiding is an iOS library that solves a common problem: when a user taps a text field on screen, the on-screen keyboard pops up and often covers the field they are trying to type into. Rather than leaving developers to write their own workaround for every screen in an app, this library provides a ready-made fix that you drop in once and it works across your whole project. The fix works through two custom view classes: a scrollable view and a table view, both of which are subclasses of standard iOS components. When the keyboard is about to appear, these classes automatically find whichever text field the user is about to edit, scroll to it, and animate it into view so it is not hidden. When the keyboard goes away, the view returns to its original size. The animation is intentionally matched to the keyboard's own pop-up animation so the transition feels natural. Setup is minimal. For screens built around a table view, you swap in the library's table view class in your interface file. For other screens, you place the library's scroll view class as the container and put all your input fields inside it. Both approaches can be done either through an interface builder file or in code directly. One extra convenience: the library also wires up the "Next" button on the keyboard automatically, so tapping it moves focus to the next text field in order. If you do not want that behavior for a particular field, you can turn it off by changing that field's return key type. The library is written in Objective-C and released under the Zlib license, which allows free use in personal and commercial apps with minimal restrictions. It is a mature project, originally authored by Michael Tyson, and its age means it has been tested against a wide range of iOS setups over the years.

Copy-paste prompts

Prompt 1
I have an iOS login screen with three text fields. Show me how to use TPKeyboardAvoidingScrollView to prevent the keyboard from covering them.
Prompt 2
How do I use TPKeyboardAvoidingTableView in a UITableViewController so that text fields inside table cells are always scrolled into view?
Prompt 3
The automatic Next key behavior in TPKeyboardAvoiding doesn't work for one of my fields, how do I disable it for a specific UITextField?
Prompt 4
Add TPKeyboardAvoiding to my iOS project via CocoaPods, show the Podfile entry and how to apply it in a storyboard.
Open on GitHub → Explain another repo

← michaeltyson on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.