How do you adjust your scrollview to compensate for a keyboard vertically? Read on...
Yes I know this is some basic info, but I randomly noticed today that all of the answers I saw about this topic are all over the place with info, versions and/or use bangs all over the place... but nothing solid for Swift 3+.
A modification to make it work on iOS 11 is to use
UIKeyboardFrameEndUserInfoKey
rather thanUIKeyboardFrameBeginUserInfoKey
. Just a simplified approach to @crewshin's solution:Swift 4.2:
Substitute scrollView for UITableView, UICollectionView, etc.
Add observers.
Add some functions to listen for the notifications:
Worth noting is that if your deployment target is iOS 9 or greater, you don't need to remove the observer anymore. Check the NotificationCenter docs for more info.
------------------------------------------------
Swift 3:
Add observers.
Add some functions to listen for the notifications:
Worth noting is that if your deployment target is iOS 9 or greater, you don't need to remove the observer anymore. Check the NotificationCenter docs for more info.