GithubHelp home page GithubHelp logo

keyboardman's Introduction

KeyboardMan

We may need keyboard infomation from keyboard notifications to do animation. However, the approach is complicated and easy to make mistakes. Even more, we need to handle the bug of system fire keyboard notifications.

But KeyboardMan will make it simple & easy.

另有中文介绍

Requirements

Swift 4.2, iOS 8.0

(Swift 3, use version 1.1.0)

Example

import KeyboardMan

Do animation with keyboard appear/disappear:

let keyboardMan = KeyboardMan()

keyboardMan.animateWhenKeyboardAppear = { [weak self] appearPostIndex, keyboardHeight, keyboardHeightIncrement in

    print("appear \(appearPostIndex), \(keyboardHeight), \(keyboardHeightIncrement)\n")

    if let self = self {

        self.tableView.contentOffset.y += keyboardHeightIncrement
        self.tableView.contentInset.bottom = keyboardHeight + self.toolBar.frame.height

        self.toolBarBottomConstraint.constant = keyboardHeight
        self.view.layoutIfNeeded()
    }
}

keyboardMan.animateWhenKeyboardDisappear = { [weak self] keyboardHeight in

    print("disappear \(keyboardHeight)\n")

    if let self = self {

        self.tableView.contentOffset.y -= keyboardHeight
        self.tableView.contentInset.bottom = self.toolBar.frame.height

        self.toolBarBottomConstraint.constant = 0
        self.view.layoutIfNeeded()
    }
}

For more specific information, you can use keyboardInfo that KeyboardMan post:

keyboardMan.postKeyboardInfo = { [weak self] keyboardMan, keyboardInfo in
    // TODO
}

Check the demo for more information.

Installation

Feel free to drag KeyboardMan.swift to your iOS Project. But it's recommended to use Carthage (or CocoaPods).

Carthage

github "nixzhu/KeyboardMan"

CocoaPods

pod 'KeyboardMan'

Contact

NIX @nixzhu

License

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

keyboardman's People

Contributors

limon-o-o avatar nixzhu avatar onevcat avatar roczhang9673 avatar xspyhack avatar xuhaoyuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keyboardman's Issues

有一个小BUG

1.点击进入编辑。此时键盘在底部
2.长按键盘右下角键盘按键。点击 拆分键盘 (split)或者 浮动键盘(undock),此时键盘分成左右两半,在屏幕中间
3.点击键盘右下角键盘按键收起,出现编辑框没收起状况

IOS10用第三方输入法的问题

IOS10上第三方输入法会闪一下,导致view改变位置的动画出现问题~
IOS10的第三方输入法框高度不是递增或递减的,从其他输入法切换到第三方输入法时会多调用一次键盘的监听方法

IOS9:
appear 9, 0.0, -216.0

appear 10, 216.0, 216.0

appear 11, 282.0, 66.0

IOS10:
appear 4, 282.0, 66.0

appear 5, 216.0, -66.0

appear 6, 282.0, 66.0

作者有解决方法么?

something wrong with animation when keyboard resignFirstResponder

In ViewController.swift File , implement UIScrollViewDelegate‘s method scrollViewWillBeginDragging. like below:

 func scrollViewWillBeginDragging(scrollView: UIScrollView) {

        self.textField.resignFirstResponder();
}

the animation of toolBar is faster than keyboard's

keyboardman

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.