AutoKeyboardScrollView is an UIScrollView subclass which makes showing and dismissing keyboard for UITextFields much easier. So called keyboard avoidance.

Overview

AutoKeyboardScrollView

CI Status Version License Platform

AutoKeyboardScrollView is a smart UIScrollView which can:

  • Scroll to proper position and make sure the active textField is visible when keyboard is showing
  • Customize top and bottom margin for textField
  • Dismiss keyboard when tap on scrollView
  • Dismiss keyboard on tap "Return"
  • New contentView which makes your life with Auto Layout easier

Preview

demo

Why?

Form views are very common when developing iOS projects. When keyboard is showing up, the big keyboard is covering great areas, which will hide the active textField.

It's kind of annoying to handle scrolling on UIScrollView and it's trivial to write keyboard notification and textField target action code again.

To keep your code DRY and make your life with iOS development easier.

Requirements

  • iOS 8.0+ / Mac OS X 10.9+
  • Xcode 7.0

Installation

CocoaPods

AutoKeyboardScrollView is available through CocoaPods. To install it, simply add the following line to your Podfile:

1.5'">
pod "AutoKeyboardScrollView", '~> 1.5'

Manually

Just drag AutoKeyboardScrollView.swift (Located in ./Source, right click and Download Linked File) into your project and use it directly.

Usage

Just use AutoKeyboardScrollView as parent view of textFields, or views contain textFields. Add subViews on autoKeyboardScrollView.contentView (Be sure to add subViews on .contentView), then it just works!

(Note, only textField which is already on the view to be added can be handled, you can manually add textFields that need to be handled by calling handleTextField: or handleTextFields:)

To run the example project, clone the repo, and run pod install from the Example directory first.

How it works?

AutoKeyboardScrollView is a subClass of UIScrollView, some key features are list as following:

contentView

A new property: contentView is added, which is served same purpose as UITableViewCell. All subviews should be added on contentView, this is extremely helpful when dealing Auto Layout with ScrollView (refer: Apple Technical Note TN2154 - UIScrollView And Autolayout)

Note: To let AutoKeyboardScrollView determine its contentSize, the height and width of contentView must be fully specified.

Dismiss keyboard on Tap

AutoKeyboardScrollView will be attached with a Tap gesture and let you dismiss keyboard by tapping the empty space around textFields.

Dismiss keyboard on "Return"

AutoKeyboardScrollView will automatically detect textFields on newly added subViews, and add UIControlEditing actions for these textField, it will let you dismiss keyboard when tap "Return".

Work with Interface Builder

Create a wrapper view in IB, then add it as a subview on autoKeyboardScrollView.contentView.

See example project and select target InterfaceBuilderExample:

targets

Requirements

Works with Auto Layout, not tested on frame based code.

Support iOS 7 and above. Not tested on iOS 6, since Auto Layout came from iOS6, should be fine.

Author

Honghao Zhang (ๅผ ๅฎๆ˜Š)

License

AutoKeyboardScrollView is available under the MIT license. See the LICENSE file for more info.

You might also like...
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

๐Ÿ„โ€โ™‚๏ธ UITextField-Navigation makes it easier to navigate between UITextFields and UITextViews
๐Ÿ„โ€โ™‚๏ธ UITextField-Navigation makes it easier to navigate between UITextFields and UITextViews

' __________________ _______ _________ _______ _________ _______ _ ______ ' |\ /|\__ __/\__ __/( ____ \|\ /

Duplicate Tab is a Safari Extension for iOS and iPadOS that makes duplicating tabs much easier!

Duplicate Tab Duplicate Tab is a Safari Extension for iOS and iPadOS that makes duplicating tabs much easier! Check it out on the App Store Privacy Po

An iOS drop-in UITableView, UICollectionView and UIScrollView superclass category for showing a customizable floating button on top of it.
An iOS drop-in UITableView, UICollectionView and UIScrollView superclass category for showing a customizable floating button on top of it.

MEVFloatingButton An iOS drop-in UITableView, UICollectionView, UIScrollView superclass category for showing a customizable floating button on top of

An executable that can be called from a Run Script Build Phase that makes comments such as // TODO: or // SERIOUS: appear in Xcode's Issue Navigator giving them project-wide visibility.

XcodeIssueGenerator An executable that can be called from a Run Script Build Phase that makes comments such as // TODO: or // SERIOUS: appear in Xcode

iOS - Subclass of UITextField to achieve autocompletion for Place Search like Google Places, Uber and Much more apps having maps.

MVAutocompletePlaceSearchTextField iOS - Subclass of UITextField to achieve autocompletion for Place Search like Google Places, Uber and Much more app

SugarRecord is a persistence wrapper designed to make working with persistence solutions like CoreData in a much easier way.
SugarRecord is a persistence wrapper designed to make working with persistence solutions like CoreData in a much easier way.

What is SugarRecord? SugarRecord is a persistence wrapper designed to make working with persistence solutions like CoreData in a much easier way. Than

NumberMorphView a view like label for displaying numbers which animate with transition using a technique called number tweening or number morphing.
NumberMorphView a view like label for displaying numbers which animate with transition using a technique called number tweening or number morphing.

NumberMorphView a view like label for displaying numbers which animate with transition using a technique called number tweening or num

Swift String Validator. Simple lib for ios to validate string and UITextFields text for some criterias

Swift String validator About Library for easy and fastest string validation based on ัciterias. Instalation KKStringValidator is available through Coc

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.
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

Custom UITextFields effects inspired by Codrops, built using Swift
Custom UITextFields effects inspired by Codrops, built using Swift

TextFieldEffects I fell in love with the text inputs effects in this article. As an exercise I decided to recreate as many of them as I can using Swif

RxBluetoothKit is a Bluetooth library that makes interaction with BLE devices much more pleasant.
RxBluetoothKit is a Bluetooth library that makes interaction with BLE devices much more pleasant.

RxBluetoothKit is a Bluetooth library that makes interaction with BLE devices much more pleasant. It's backed by RxSwift and CoreBluetooth and it prov

UIScrollView subclass that allows to add a list of highly customizable tags.
UIScrollView subclass that allows to add a list of highly customizable tags.

UIScrollView subclass that allows to add a list of highly customizable tags. You can customize colors, border radius, and the tail of the tag. Tags ca

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

TTGSnackbar shows simple message and action button on the bottom or top of the screen with multi kinds of animation, which is written in Swift3 and inspired by Snackbar in Android. It also support showing custom view, icon image or multi action button. KDEDateLabel is an UILabel subclass that updates itself to make time ago's format easier.
KDEDateLabel is an UILabel subclass that updates itself to make time ago's format easier.

KDEDateLabel KDEDateLabel is an UILabel subclass that saves you from refreshing it when using 'time ago' format. Installation You have multiple choice

This is an app for a craft beer company called Cacique Bier that allows to see their available products and place orders. Made with Swift and SwiftUI.

Cacique Bier App This is an app for a Craft Beer company that shows their catalogue of products and in the future will allow purchases. The app is com

CompositionalLayoutDSL, library to simplify the creation of UICollectionViewCompositionalLayout. It wraps the UIKit API and makes the code shorter and easier to read.
CompositionalLayoutDSL, library to simplify the creation of UICollectionViewCompositionalLayout. It wraps the UIKit API and makes the code shorter and easier to read.

CompositionalLayoutDSL CompositionalLayoutDSL is a Swift library. It makes easier to create compositional layout for collection view. Requirements Doc

OysterKit is a framework that provides a native Swift scanning, lexical analysis, and parsing capabilities. In addition it provides a language that can be used to rapidly define the rules used by OysterKit called STLR

OysterKit A Swift Framework for Tokenizing, Parsing, and Interpreting Languages OysterKit enables native Swift scanning, lexical analysis, and parsing

Comments
Releases(1.5)
Owner
HongHao Zhang
๐Ÿ”จ
HongHao Zhang
GoAutoSlideView extends UIScrollView by featuring infinitely and automatically slide.

GoAutoSlideView GoAutoSlideView extends UIScrollView by featuring infinitely and automatically slide. #ScreenShot Installation ###CocoaPods pod 'GoAut

Jamie 57 Jan 12, 2021
A data-driven UIScrollView + UIStackView framework for building fast and flexible lists

JKListKit A data-driven UIScrollView + UIStackView framework for building fast and flexible lists. Full Oficial documentation Main Features ?? Create

Juan Vasquez 2 Mar 15, 2022
HPParallaxHeader is a simple parallax header class for UIScrollView.

HPParallaxHeader is a simple parallax header class for UIScrollView.

null 40 Dec 15, 2022
UIScrollView โˆž scroll category

UIScrollView+InfiniteScroll Infinite scroll implementation as a category for UIScrollView. * The content used in demo app is publicly available and pr

Andrej Mihajlov 1k Dec 29, 2022
Multi-tier UIScrollView nested scrolling solution. ๐Ÿ˜‹๐Ÿ˜‹๐Ÿ˜‹

Multi-tier UIScrollView nested scrolling solution. Snapshots Requirements iOS 9.0+ Xcode 10.0+ Swift 4.2+ Installation CocoaPods CocoaPods is a depend

Jiar 1.2k Dec 30, 2022
CrownControl is a tiny accessory that makes scrolling through scrollable content possible without lifting your thumb.

CrownControl Overview Features Example Project Requirements Installation Usage Quick Usage Crown Attributes Scroll Axis Anchor Position Spin Direction

Daniel Huri 96 Dec 27, 2022
A scroll view with a sticky header which shrinks as you scroll. Written with SwiftUI.

Scaling Header Scroll View A scroll view with a sticky header which shrinks as you scroll. Written with SwiftUI. We are a development agency building

Exyte 395 Dec 31, 2022
SwiftUI, peek scrolling animation and card tapped animation, using GeometryReader

SwiftUI, peek scrolling animation and card tapped animation, using GeometryReader, follow the livestream tutorial by MengTo.

Terry Kuo 4 Jun 10, 2022
A SwiftUI ScrollView Designed to imitate the App Store and Apple Music ScrollViews (with or without a Parallax Header)

FancyScrollView I spent a lot of time looking for a way to recreate the UI of the ScrollViews in Stock Apple Apps (i.e. App Store and Apple Music) ins

Mathias Quintero 696 Dec 30, 2022
โ†•๏ธ VegaScroll is a lightweight animation flowlayout for UICollectionView completely written in Swift 4, compatible with iOS 11 and Xcode 9.

Made by Applikey Solutions Find this project on Dribbble Also check another flowlayout for UICollectionView: https://github.com/ApplikeySolutions/Grav

Applikey Solutions 2.8k Jan 7, 2023