Skip to content

Latest commit

 

History

History
43 lines (24 loc) · 1.59 KB

README.md

File metadata and controls

43 lines (24 loc) · 1.59 KB

Synopsis:

This class scrolls the screen upwards when the virtual keyboard is shown so that it doesn't cover the actual text field.

Description:

There are many solutions to the annoying problem of having the virtual keyboard cover the currently focused UITextField. I've seen some use a good universal implementation like IQKeyboardManager BUT they are not updated for use with or without Autolayout or other issues. This solution is fairly simple and adds a UIScrollView between your UIView and it's superview automatically. Sometimes simple is best. It works for views that use Autolayout constraints or just plain resizing masks.

How to use:

  1. Create an instance of KeyboardHelper.

let keyboardHelper = KeyboardHelper()

  1. Add it to the superview of the UITextField or the view you wish to be scrolled up.

keyboardHelper.addTo(view: content)

Optionally: add your code in for the keyboard events

onKeyboardWillBeShown

onKeyboardWillBeResized

onKeyboardWillBeHidden

See the demo project KeyboardDemo for an example. or try it on Appetize

How it works:

When you attach it to a view it adds a UIScrollView as it's superview that uses the view as it's content.

It also adds a gesture recognizer that resigns the current first responder when tapped.

Contact the author:

For any bugs, changes or requests please contact me by email: [email protected] or check out my site www.wfff.info

Thanks.