Skip to content
No description, website, or topics provided.
Shell Objective-C Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
EDKeyboardHandler
Example
.gitignore
.travis.yml
EDKeyboardHandler.podspec
LICENSE
README.md
_Pods.xcodeproj

README.md

EDKeyboardHandler

[![CI Status](http://img.shields.io/travis/Eren Demirbuken/EDKeyboardHandler.svg?style=flat)](https://travis-ci.org/Eren Demirbuken/EDKeyboardHandler) Version License Platform

Usage

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

just init and listen to keyboard with block

  self.keyboardHandler = [EDKeyboardHandler new];
    
  [self.keyboardHandler listenWithBlock:^(KeyboardInfo *model)
  {
    //adjust view positions according to keyboard position here
  }];

KeyboardHandler also provides KeyboardHandlerDelegate to listen keyboard position with delegation

@protocol KeyboardHandlerDelegate <NSObject>
@optional
- (void)currentKeyboardInfo:(KeyboardInfo *) keyboardInfo;
@end

KeyboardInfo model has the following properties:

typedef enum : NSUInteger {
    KeyboardStatusDidShow,
    KeyboardStatusWillShow,
    KeyboardStatusDidHide,
    KeyboardStatusWillHide,
} KeyboardStatus;

@interface KeyboardInfo:NSObject

@property (nonatomic,readonly) NSTimeInterval animationDuration;
@property (nonatomic,readonly) CGRect keyboardFrame;
@property (nonatomic,readonly) NSInteger animationCurve;
@property (nonatomic,readonly) KeyboardStatus status;

@end

TL;DR sample usage:

    self.keyboardHandler = [EDKeyboardHandler new];
 
    [self.keyboardHandler listenWithBlock:^(KeyboardInfo *keyboardInfo)
    {
      if (keyboardInfo.status == KeyboardStatusWillShow || keyboardInfo.status == KeyboardStatusDidShow)
       {
          CGRect inputViewFrame = self.inputView.frame;
          inputViewFrame.origin.y = keyboardInfo.keyboardFrame.origin.y - inputViewFrame.size.height ;
          self.inputView.frame = inputViewFrame;
          
      }else{
          //handle keyboard hiding here
      }
    }];

Screen shot

alt tag

Requirements

Installation

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

pod "EDKeyboardHandler"

Author

Eren Demirbuken, erendemirbuken@peakgames.net

License

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

You can’t perform that action at this time.