Skip to content

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

License

Notifications You must be signed in to change notification settings

wfettich/KeyboardHelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages