Objective-C library for tracking keyboard in iOS apps.

Overview

NgKeyboardTracker

Objective-c library for tracking keyboard in iOS apps.

Adding to your project

If you are using CocoaPods, add to your Podfile:

pod 'NgKeyboardTracker'

To manually add to your projects:

  1. Add files in NgKeyboardTracker folder to your project.
  2. Add these frameworks to your project: UIKit.

Features

NgKeyboardTracker encapsulates keyboard tracking for iOS apps. It provides convenience to query keyboard's properties anywhere in your application.

You can also use NgKeyboardTracker to implement iMessage's text input behavior on iOS 7 (UIScrollViewKeyboardDismissModeInteractive + persistent inputAccessoryView) using NgPseudoInputAccessoryViewCoordinator.

Usage

Start and stop keyboard tracking

In your application delegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [[NgKeyboardTracker sharedTracker] start]; // start tracking
  return YES;
}

- (void)applicationWillTerminate:(UIApplication *)application {
  // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  [[NgKeyboardTracker sharedTracker] stop]; // stop tracking
}

Responding to keyboard updates

  1. Implement NgKeyboardTrackerDelegate protocol.
  2. Register as delegate by calling -addDelegate: method
  3. Make sure to call -removeDelegate: to stop receiving keyboard updates

Keyboard tracker's properties:

  • appearanceState : current appearance state
  • beginFrame : last known begin frame
  • endFrame: last known frame
  • currentFrame: last known current keyboard's frame
  • animationDuration: last known animation duration
  • animationCurve: last known animation curve
  • animationOptions : derived from animationCurve for convenience

P.S. keyboard's frame.size.height system's keyboard height plus inputAccessoryView height.

Pseudo input accessory view coordinator

NgPseudoInputAccessoryViewCoordinator is NgKeyboardTracker extension that makes it easier to implement iMessage's text input behavior in iOS 7 with UIScrollViewKeyboardDismissModeInteractive and persistent inputAccessoryView.

The view controller:

  1. Override loadView to set custom UIView implementation.
  2. Make sure to call the custom view's becomeFirstResponder.

The custom view:

  1. Create NgPseudoInputAccessoryViewCoordinator by calling -createPseudoInputAccessoryViewCoordinator.
  2. Overrides -canBecomeFirstResponder, returns YES.
  3. Overrides -inputAccessoryView, returns coordinator's pseudoInputAccessoryView.
  4. Set UIScrollView's keyboard dismiss mode to UIScrollViewKeyboardDismissModeInteractive.
  5. Set desired height of input accessory view with -setPseudoInputAccessoryViewHeight:.
  6. Layout keyboard's bar accordingly using information from NgKeyboardTracker in layoutSubviews.

P.S. See demo application for example.

You might also like...
Slidden is an open source, customizable, iOS 8 keyboard, written in Swift
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

Emoji Keyboard for iOS
Emoji Keyboard for iOS

English | 中文 An easy to use Emoji keyboard for iOS. Has been rewritten with swift, the old Objective-C version on branch oc. Features Written in Swift

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

A simple keyboard to use with numbers and, optionally, a decimal point.
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

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

Comments
  • Apple Match-O Linker Error

    Apple Match-O Linker Error

    Hello!

    I am getting the following error after I put the code in the AppDelegate.m file:

    ld: warning: directory not found for option '-L/Users/seung/Desktop/Websites/FirstApp/build/Debug-iphoneos' Undefined symbols for architecture i386: "OBJC_CLASS$_NgKeyboardTracker", referenced from: objc-class-ref in AppDelegate.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

    Any help would be appreciated. Thank you!

    opened by ghost 5
  • Correct the spelling of CocoaPods in README

    Correct the spelling of CocoaPods in README

    This pull requests corrects the spelling of CocoaPods 🤓 https://github.com/CocoaPods/shared_resources/tree/master/media

    Created with cocoapods-readme.

    opened by ReadmeCritic 0
Owner
Meiwin Fu
Meiwin Fu
Prevent keyboard from covering UITextField/UITextView, includes Swift and Objective-C APIs

Prevent keyboard from covering UITextField/UITextView with only one line of code, includes Swift and Objective-C APIs.

LiuChang 8 Oct 24, 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
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
Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more.

IQKeyboardManager While developing iOS apps, we often run into issues where the iPhone keyboard slides up and covers the UITextField/UITextView. IQKey

Mohd Iftekhar Qurashi 15.9k Jan 8, 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
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
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

Michael Tyson 5.8k Dec 26, 2022
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

Makemoji 100 Nov 3, 2022
A Chinese keyboard for iOS that helps Chinese language learners remember tones.

ToneBoard ToneBoard is a Chinese keyboard for iOS that requires you to enter the correct tones while typing simplified Chinese with Pinyin. It is avai

Kevin Bell 7 Sep 27, 2022
SwiftyKeyboard: a full customized numeric keyboard for iOS

SwiftyKeyboard Overview SwiftyKeyboard is an iOS customized enhanced keyboard. T

SwiftyKit 2 Jun 30, 2022