• Stars
    star
    100
  • Rank 340,703 (Top 7 %)
  • Language
    Objective-C
  • License
    Apache License 2.0
  • Created over 10 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An easy-to-use Objective-C protocol that automatically resizes / adjusts views when a keyboard appears on iOS.

For the Swift port of this project, please see KeyboardAdjuster.

LHSKeyboardAdjusting

CI Status Version License Platform

LHSKeyboardAdjusting will adjust the bottom position of your UIScrollView or UITableView when a keyboard appears on screen using Auto Layout. All you have to do is provide LHSKeyboardAdjusting with an NSLayoutConstraint that pins the bottom of your view to the bottom of the screen. LHSKeyboardAdjusting will automatically adjust that constraint and pin it to the top of the keyboard when it appears.

LHSKeyboardAdjusting requires Auto Layout in your build target, so it will only work with iOS 6+.

NOTE

If you're currently using LHSKeyboardAdjusting 1.0+ in your project, note that some things have changed.


Installation

LHSKeyboardAdjusting uses CocoaPods, so in your Podfile, just add something like this:

pod 'LHSKeyboardAdjusting', '~> 2.0'

Then run pod install and you'll be ready to go.

If you don't use CocoaPods, dragging and dropping the LHSKeyboardAdjusting folder into your Xcode project will do the trick as well.

Usage

  1. In your view controller's header file, assign the LHSKeyboardAdjusting protocol to your class and define an NSLayoutConstraint property called keyboardAdjustingBottomConstraint.

    #import <LHSKeyboardAdjusting/LHSKeyboardAdjusting.h>
    
    @interface ViewController : UIViewController <LHSKeyboardAdjusting>
    
    @property (nonatomic, strong) NSLayoutConstraint *keyboardAdjustingBottomConstraint;
    
    @end
  2. In your view controller, implement keyboardAdjustingView to return the view you'd like to pin to the top of the keyboard. It could be anything, but a UIScrollView, UITableView, or a UITextView are the most likely candidates.

    #pragma mark - LHSKeyboardAdjusting
    
    - (UIView *)keyboardAdjustingView {
        return self.tableView;
    }
  3. Activate and deactivate the automatic adjustments in viewWillAppear and viewWillDisappear.

    #import <LHSKeyboardAdjusting/UIViewController+LHSKeyboardAdjustment.h>
    
    @implementation ViewController
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
    
        [self lhs_activateKeyboardAdjustment];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
        [super viewWillDisappear:animated];
    
        [self lhs_deactivateKeyboardAdjustment];
    }
    
    @end

    Note: you can also define callbacks on keyboard appearance or disappearance using lhs_activateKeyboardAdjustmentWithShow:hide::

    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
    
        [self lhs_activateKeyboardAdjustmentWithShow:^{
            NSLog(@"hi");
        } hide:^{
            NSLog(@"bai");
        }];
    }
  4. And you're done! Whenever a keyboard appears, this view will be automatically resized.

If you need more pointers on how to set everything up, clone this repo and check out the included example project (LHSKeyboardAdjustingExample).

License

Apache 2.0, see LICENSE file for details.

More Repositories

1

bottlenose

A Python wrapper for the Amazon Product Advertising API.
Python
578
star
2

pinboard.py

A full-featured Python wrapper (and command-line utility) for the Pinboard API. Built by the makers of Pushpin for Pinboard.
Python
342
star
3

openradar-mirror

A mirror of radars pulled from http://openradar.me/.
Python
246
star
4

django-pyodbc

An ODBC-powered MS SQL Server DB backend for Django 1.4+
Python
203
star
5

git-bigstore

Bigstore is a Git extension that helps you track big files in your repositories.
Python
183
star
6

ConcentricProgressRingView

Fully customizable circular progress bar written in Swift.
Swift
143
star
7

ASPinboard

A modern, fast, and flexible Objective-C library for Pinboard.in.
Objective-C
83
star
8

TipJarViewController

Easy, drop-in tip jar for iOS apps.
Swift
78
star
9

requests-cloudkit

Apple CloudKit Python library.
Python
70
star
10

django-template

A battle-tested Django 2.1 project template with configurations for AWS, Heroku, App Engine, and Docker.
Python
64
star
11

in_app_purchase_receipt_verifier

A simple, one-click deploy web app to simplify the process of validating In-App Purchase receipts on the App Store.
Python
58
star
12

python-harvest

A Python wrapper for the Harvest time-tracking API.
Python
55
star
13

SuperLayout

SuperLayout is a Swift library that makes using Auto Layout a breeze.
Swift
52
star
14

django-on-appengine-archive

Jumpstart Django development on Google Appengine.
Python
49
star
15

pwnedpasswords

A Python Library and CLI for the Pwned Passwords v2 API
Python
47
star
16

KeyboardAdjuster

A Swift library that automatically resizes and adjusts views to scroll when a keyboard appears.
Swift
40
star
17

objectifier

Objectify your Python objects.
Python
37
star
18

TimeTracker-Linux

A Harvest client for Ubuntu Linux.
Python
21
star
19

Notchy

Notchy is an iOS app that makes pretty, shareable screenshots for the iPhone X and the iPhone XS.
Swift
20
star
20

LionheartExtensions

An invaluable collection of Swift extensions and utilities for iOS.
Swift
14
star
21

django-pwnedpasswords-validator

Django password validator that checks for passwords in known data breaches.
Python
13
star
22

python-onfleet

A full-featured Python wrapper for the Onfleet API.
Python
11
star
23

TableViewPopoverPresenting

Display popovers on taps over your table views cells. It was hard. Now it's easy.
Swift
9
star
24

QuickTableView

UITableView toolset for Swift.
Swift
9
star
25

python-leafly

Python
8
star
26

django-lionheart-helpers

A small collection of utilities for use with Django.
Python
8
star
27

django-statictastic

A Django app that makes it easy to sync static files to your storage backend of choice.
Python
8
star
28

python-restmapper

RestMapper takes the pain out of integrating with RESTful APIs.
Python
8
star
29

LionheartCurrencyTextField

A drop-in replacement for UITextField that displays currency values the way you’d expect it to.
Swift
8
star
30

LHSFontSelectionViewController

Objective-C
7
star
31

WelcomeViewController

A welcome view in the style of Apple's built-in apps.
Swift
7
star
32

LHSColorPickerView

Objective-C
4
star
33

fastlane-plugin-submit_to_beta_app_review

A simple plugin that submits an iTunes Connect build to Beta App Review.
Ruby
4
star
34

Health-XML-Splitter

A macOS utility that splits Health XML files into smaller chunks.
Swift
4
star
35

pushpin-localizations

Translations for Pushpin, a Pinboard client for iOS.
Shell
3
star
36

LHSDelicious

An easy-to-use Objective-C wrapper for the Delicious API.
Objective-C
3
star
37

Xcode-Templates

Makefile
3
star
38

LHSCategoryCollection

A collection of helpful categories for use in iOS projects.
Objective-C
3
star
39

style-guide

2
star
40

LHSCategoriesFlowView

Objective-C
2
star
41

iOSTipsTricks

Objective-C
2
star
42

IAPReceiptVerifier

Companion iOS library to https://github.com/lionheart/in_app_purchase_receipt_verifier
Swift
2
star
43

LHSKippt

not much to see here, move along
Objective-C
2
star
44

milestonemaker

Just a quick and dirty script that creates weekly milestones in GitHub issues.
Python
2
star
45

UncommonCrypto

Pure Swift wrapper for CommonCrypto.
HTML
2
star
46

LHSDiigo

Objective-C
2
star
47

LionheartOtherAppsViewController

A view controller that showcases all the apps you currently have on the App Store.
Swift
2
star
48

LHSTableViewCells

A Pod that allows you to make tableViewCells without subclassing them
Objective-C
1
star
49

LHSTwitterFollowUtility

A utility that allows your users to follow a specific twitter account.
Objective-C
1
star
50

mixpanel-people-delete

A one-click Heroku app that resets your Mixpanel People usage.
Python
1
star
51

github-issues-tools

Python
1
star
52

LHSCustomTransitionCollection

A collection of custom transitions for use in iOS 7+
Objective-C
1
star
53

releasemaker

Python
1
star
54

LionheartAlamofireClient

A simple class that helps manage interaction with remote APIs using Alamofire.
Swift
1
star
55

LHSOtherAppsViewController

A view controller to show your users the other apps that you have developed.
Objective-C
1
star
56

lionheart-tumblr-theme

The Lionheart Software Tumblr Blog Theme
CSS
1
star