Prevent keyboard from covering UITextField/UITextView, includes Swift and Objective-C APIs

Overview

KeyboardListener

Prevent keyboard from covering UITextField/UITextView, includes Swift and Objective-C APIs.

Requirements

  • iOS 9.0+
  • Swift 4.0+

Usage

  • Swift
let textView = UITextView(frame: CGRect(x: 20, y: self.view.frame.height-100, width: 200, height: 45))

textView.backgroundColor = UIColor.red
self.view.addSubview(textView)

let textField = UITextField(frame: CGRect(x: 20, y: self.view.frame.height-160, width: 200, height: 45))
textField.backgroundColor = UIColor.yellow
self.view.addSubview(textField)

// add
self.view.addKeyboardListener()
  • Objective-C
UITextField *t = [[UITextField alloc] init];
t.frame = CGRectMake(100, self.view.frame.size.height - 300, 100, 50);
t.backgroundColor = [UIColor redColor];
[self.view addSubview:t];

UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 200, self.view.frame.size.width, 50)];
contentView.backgroundColor = UIColor.yellowColor;
[self.view addSubview:contentView];
UITextView *t2 = [[UITextView alloc] init];
t2.frame = CGRectMake(100, 0, 100, 50);
t2.backgroundColor = [UIColor grayColor];
[contentView addSubview:t2];

// add
[self.view lc_addKeyboardListener];

Installation

CocoaPods

To integrate KeyboardListener into your Xcode project using CocoaPods, specify it in your Podfile:

  • Swift
pod 'KeyboardListener'
  • Objective-C
pod 'LCKeyboardListener'

Manual

  • Swift
  1. Download everything in the KeyboardListener folder;
  2. Add (drag and drop) the source files in KeyboardListener to your project.
  • Objective-C
  1. Download everything in the KeyboardListener folder;
  2. Add (drag and drop) the source files in LCKeyboardListener to your project;
  3. Import UIView+LCKeyboardListener.h.

License

KeyboardListener is provided under the MIT license. See LICENSE file for details.

You might also like...
IHKeyboardAvoiding is an elegant solution for keeping any UIView visible when the keyboard is being shown - no UIScrollView required!
IHKeyboardAvoiding is an elegant solution for keeping any UIView visible when the keyboard is being shown - no UIScrollView required!

IHKeyboardAvoiding An elegant solution for keeping any UIView visible when the keyboard is being shown Requirements IHKeyboardAvoiding Version Objecti

⌨️ Add user-customizable global keyboard shortcuts to your macOS app in minutes
⌨️ Add user-customizable global keyboard shortcuts to your macOS app in minutes

This package lets you add support for user-customizable global keyboard shortcuts to your macOS app in minutes. It's fully sandbox and Mac App Store c

Suppress mouse & keyboard events on MacOSX. Baby-proof my Mac!

Suppress mouse & keyboard events on MacOSX Catches all events (mouse, keyboard, everything), and either consumes them (locked state) or passes them th

QMK Agent is a macOS menubar application which sends commands to a QMK enabled keyboard
QMK Agent is a macOS menubar application which sends commands to a QMK enabled keyboard

QMKagent QMK Agent is a macOS menubar application which sends commands to a QMK enabled keyboard Features System volume indicator using top row (Esc t

Showing / dismissing keyboard animation in simple UIViewController category.
Showing / dismissing keyboard animation in simple UIViewController category.

RSKKeyboardAnimationObserver Easy way to handle iOS keyboard showing/dismissing. Introduction Working with iOS keyboard demands a lot of duplicated co

For less complicated keyboard event handling.

KeyboardObserver For less complicated keyboard event handling. Features Less complicated keyboard event handling. Do not use Notification , but event

A drop-in universal solution for moving text fields out of the way of the keyboard in iOS

TPKeyboardAvoiding A drop-in universal solution for moving text fields out of the way of the keyboard in iOS. Introduction There are a hundred and one

KeyboardMan helps you to make keyboard animation.

KeyboardMan We may need keyboard infomation from keyboard notifications to do animation. However, the approach is complicated and easy to make mistake

Emoji Keyboard SDK (iOS)
Emoji Keyboard SDK (iOS)

Makemoji SDK Makemoji is a free emoji keyboard for mobile apps. By installing our keyboard SDK every user of your app will instantly have access to ne

Owner
LiuChang
iOS Developer!
LiuChang
iOS utility class allows you to access keyboard view and track keyboard animation.

YYKeyboardManager iOS utility class allows you to access keyboard view and track keyboard animation. (It was used by YYText) Compatibility iPhone / iP

null 480 Nov 17, 2022
Objective-C library for tracking keyboard in iOS apps.

NgKeyboardTracker Objective-c library for tracking keyboard in iOS apps. Adding to your project If you are using CocoaPods, add to your Podfile: pod '

Meiwin Fu 808 Nov 17, 2022
KeyboardKit is a Swift library that helps you create custom keyboard extensions for iOS and ipadOS.

KeyboardKit is a Swift library that helps you create custom keyboard extensions for iOS and ipadOS.

KeyboardKit 900 Jan 9, 2023
A simple keyboard to use with numbers and, optionally, a decimal point.

MMNumberKeyboard A simple keyboard to use with numbers and, optionally, a decimal point. Installation From CocoaPods CocoaPods is a dependency manager

Matías Martínez 957 Nov 17, 2022
⌨️A Combine-based way to observe and adjust for Keyboard notifications in SwiftUI

⌨️ Keyboard Observing A Combine-based solution for observing and avoiding the keyboard in SwiftUI. Table of Contents About Requirements Installation C

Nick Fox 440 Jan 5, 2023
Codeless manager to hide keyboard by tapping on views for iOS written in Swift

KeyboardHideManager KeyboardHideManager - codeless manager to hide keyboard by tapping on views for iOS written in Swift. Structure Features Requireme

Bondar Yaroslav 55 Oct 19, 2022
Swift UIKit keyboard manager for iOS apps.

Typist Typist is a small, drop-in Swift UIKit keyboard manager for iOS apps. It helps you manage keyboard's screen presence and behavior without notif

Toto Tvalavadze 1.1k Dec 10, 2022
Best way to dismiss Keyboard in a View Controller iOS (Swift)

Best way to dismiss Keyboard in a View Controller iOS (Swift) First way: Implement UITextFieldDelegate’s textFieldShouldReturn method and dismiss curr

null 0 Dec 18, 2021
Interactive Keyboard Controller for Swift

Keynode Why Using UIScrollViewKeyboardDismissMode added in iOS7, interactive keyboard operation became possible. But, it only works on UIScrollView. K

Kyohei Ito 76 Sep 1, 2020
Slidden is an open source, customizable, iOS 8 keyboard, written in Swift

Slidden is an open source, customizable, iOS 8 keyboard, written in Swift. iOS 8 brought us the ability to create fully customizable keyboards, but do

Daniel Brim 595 Jan 5, 2023