Latest 1.0.3
Homepage https://github.com/rtoshiro/TXViewKeyboardResizer
License MIT
Platforms ios 6.0, requires ARC
Authors

Version
License
Platform

It automatically resizes you UIView when keyboard appears.

It can be used with any kind of UIViews.

If your view extends a UIScrollView, you need to adjust your UIScrollView.contentSize after resizing.

It was inspired by android:windowSoftInputMode="adjustResize" from Android.

Usage

First, choose the UIView that is going to be resized when keyboards appears.

Controller

Then, you need to check your Autolayout configuration or Autoresize values.

Here, i am going to use Autoresize as it is a little bit easier in that case.

Autoresize

With autoresize configured, when UIView resizes, our UITextField is positioned automaticaly.

Now we can call startKeyboardResizerObserver(WithDelegate:) inside our UIViewController:

- (void)viewDidAppear:(BOOL)animated
{
  [super viewDidAppear];

  [self.scrollView startKeyboardResizerObserverWithDelegate:self];
}

We must remember stop observing when we are done with keyboard:

- (void)viewWillDisappear:(BOOL)animated
{
  [super viewWillDisappear:animated];

  [self.scrollView stopKeyboardResizerObserver];
}

Delegate

And then, you can adjust your view per need:

- (void)viewWillResize:(UIView *)view;
- (void)viewDidResize:(UIView *)view;
- (void)viewDidTap:(UIView *)view;

We can close the keyboard, for example:

- (void)viewDidTap:(UIView *)view
{
  for (UIView *subview in self.scrollView.subviews)
  {
    if ([subview isMemberOfClass:[UITextField class]])
      [((UITextField *)subview) resignFirstResponder];
  }
}

Resize

Requirements

iOS 6.+

Installation

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

pod "TXViewKeyboardResizer"

License

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

Latest podspec

{
    "name": "TXViewKeyboardResizer",
    "version": "1.0.3",
    "summary": "UIView+KeyboardResizer category to allow the target view to resize itself according to UIKeyboardView size",
    "description": "# TXViewKeyboardResizernnIt automatically resizes you UIView when keyboard appears.nnIt can be used with any kind of UIViews.nnIf your view extends a UIScrollView, you need to adjust your UIScrollView.contentSize.nn## UsagennFirst, choose the UIView that is going to be resized when keyboards appears.nn![Controller](https://github.com/rtoshiro/TXViewKeyboardResizer/blob/master/readme/01.png)nnThen, you need to check your Autolayout configuration or Autoresize values.nnHere, i am going to use Autoresize as it is a little bit easier in that case.nn![Autoresize](https://github.com/rtoshiro/TXViewKeyboardResizer/blob/master/readme/02.png)nnWith autoresize configured, when UIView resizes, our UITextField is positioned automaticaly.nnNow we can call startKeyboardResizerObserver(WithDelegate:) inside our UIViewController:nn```n- (void)viewDidLoadn{n[super viewDidLoad];nn[self.scrollView startKeyboardResizerObserverWithDelegate:self];n}n```nWe must remember stop observing when we are done with keyboard:nn```n- (void)viewWillDisappear:(BOOL)animatedn{n[super viewWillDisappear:animated];nn[self.scrollView stopKeyboardResizerObserver];n}n```nn## DelegatennAnd then, you can adjust your view per need:nn```n- (void)viewWillResize:(UIView *)view;n- (void)viewDidResize:(UIView *)view;n- (void)viewDidTap:(UIView *)view;n```nnWe can close the keyboard, for example:nn```n- (void)viewDidTap:(UIView *)viewn{nfor (UIView *subview in self.scrollView.subviews)n{nif ([subview isMemberOfClass:[UITextField class]])n[((UITextField *)subview) resignFirstResponder];n}n}n```nn![Resize](https://github.com/rtoshiro/TXViewKeyboardResizer/blob/master/readme/01.gif)nnnn## RequirementsnniOS 6.+nn## InstallationnnTXViewKeyboardResizer is available through [CocoaPods](http://cocoapods.org). To installnit, simply add the following line to your Podfile:nn```rubynpod "TXViewKeyboardResizer"n```nn## LicensennTXViewKeyboardResizer is available under the MIT license. See the LICENSE file for more info.",
    "homepage": "https://github.com/rtoshiro/TXViewKeyboardResizer",
    "license": "MIT",
    "authors": {
        "rtoshiro": "[email protected]"
    },
    "source": {
        "git": "https://github.com/rtoshiro/TXViewKeyboardResizer.git",
        "tag": "1.0.3"
    },
    "platforms": {
        "ios": "6.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "TXViewKeyboardResizer": [
            "Pod/Assets/*.png"
        ]
    }
}

Pin It on Pinterest

Share This